码迷,mamicode.com
首页 > Windows程序 > 详细

C# MSMQ操作

时间:2015-09-21 12:04:06      阅读:203      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!