首页 > Windows开发 > 详细

C# MSMQ操作

时间:2015-09-21 12:03:58      阅读:415      评论:0      收藏:0      [点我收藏+]

//MSMQ path
string qPath = ".\\private$\\fids_input";

//send msg to Q
public void sendMsg(string content)
{
try
{
System.Text.UTF8Encoding oEncoder = new System.Text.UTF8Encoding();


MessageQueue msgQ = new MessageQueue(qPath);
System.Messaging.Message msg = new System.Messaging.Message();

msg.Label = "PARSRqeuest";
//msg.Formatter = new XmlMessageFormatter(new Type[] { typeof(string) });
//发消息到队列中
System.IO.MemoryStream ms = new System.IO.MemoryStream(oEncoder.GetBytes(content));
msg.BodyStream = ms;
msg.UseDeadLetterQueue = false;
msg.UseJournalQueue = false;
msgQ.Send(msg);

msg = null;
msgQ.Close();
msgQ = null;
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}

C# MSMQ操作

原文:http://www.cnblogs.com/lsp003/p/4825552.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!