首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

msmq复杂格式讯息发送和接收

2011-12-15 
msmq复杂格式消息发送和接收?各位大虾,我想请教一下。net下利用msmq来发送和接收复杂消息的实现,比如我发送

msmq复杂格式消息发送和接收?
各位大虾,我想请教一下。net下利用msmq来发送和接收复杂消息的实现,比如我发送一个xml文件,在接收方应该如何实现接收,或则是二进制文件的发送和接收,请帮忙,谢谢!

[解决办法]
顶啊
[解决办法]
private void local_msg_send_Click(object sender, EventArgs e)
{
//本地消息发送 二进制格式文件传输
CreateQueue(@".\private$\TSS_MsmqTest");
CreateQueue(@".\private$\TSS_MsmqTest_QueueAdministration");
try
{
this.localMessageQueue = new MessageQueue(local_mq.Text);

System.IO.FileStream inFile = new FileStream("C:\\zhouxingchi.mp3", System.IO.FileMode.Open, System.IO.FileAccess.Read);
byte[] binaryData = new byte[inFile.Length];
inFile.Read(binaryData, 0, (int)inFile.Length);
string mStr = Convert.ToBase64String(binaryData);
string hh = mStr;

System.Messaging.Message Msg = new System.Messaging.Message(binaryData, new BinaryMessageFormatter());
//使用BinaryMessageFormatter这个类型进行串行化,默认情况下,这个属性不进行赋值的话就是XmlMessageFormatter
//System.Messaging.Message Msg = new System.Messaging.Message();
// Msg.Formatter = new BinaryMessageFormatter();
Msg.AdministrationQueue = new MessageQueue(@".\private$\TSS_MsmqTest_QueueAdministration");
Msg.AcknowledgeType = AcknowledgeTypes.PositiveReceive | AcknowledgeTypes.PositiveArrival;
Msg.Label = "[mp3音乐]";
//Msg.Body = mStr;
localMessageQueue.Send(Msg);
localMessageQueue.Close();
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.ToString());


}

热点排行