关于DotNET 2.0中的MSMQ(Microsoft Message Queue)的问题 [英] A Question About MSMQ(Microsoft Message Queue) in DotNET 2.0

查看:98
本文介绍了关于DotNET 2.0中的MSMQ(Microsoft Message Queue)的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当下面的代码执行时,btnSendMessage_Click方法(发送消息)可以正常完成。但是btnReceiveMessage_Click方法阻塞'queue.Receive();'没有任何异常。为什么无法接收消息?我是否需要配置我的操作系统(Windows XP)?
任何帮助将不胜感激!

When the code below executes,the btnSendMessage_Click method(Send Message) can complete normally.
But the btnReceiveMessage_Click method blocks at 'queue.Receive();' without any exception.Why can't
receive message?Do I need to configure my OS(Windows XP) yet ?
Any help will be appreciated!

// Send Message
private void btnSendMessage_Click(object sender, System.EventArgs e)
{

// Open queue
System.Messaging.MessageQueue queue =
new System.Messaging.MessageQueue(".\\Private$\\MSMQDemo");

// Create message
System.Messaging.Message message = new System.Messaging.Message();

message.Body = txtMessage.Text.Trim();

message.Formatter = new System.Messaging.XmlMessageFormatter(new Type[] {typeof(string)});

// Put message into queue
queue.Send(message);

}



// Receive Message
private void btnReceiveMessage_Click(object sender, System.EventArgs e)
{

// Open queue
System.Messaging.MessageQueue queue =
new System.Messaging.MessageQueue(".\\Private$\\MSMQDemo");


// Receive message
System.Messaging.Message message = queue.Receive();

message.Formatter = new System.Messaging.XmlMessageFormatter(new Type[] {typeof(string)});

txtReceiveMessage.Text = message.Body.ToString();
}

推荐答案

令我惊讶的是,当我在Windows XP中使用计算机管理工具时,队列中不存在发送的消息。但是发送消息的过程不会导致异常!为什么,为什么?
To my surprise,when I use the Computer Management tool in Windows XP,the message sent doesn't exist in the queue.
But the process of sending message doesn't result in an exception!Why,why?


这篇关于关于DotNET 2.0中的MSMQ(Microsoft Message Queue)的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆