新建一个专用队列:ydzjgqueue 发出消息: MessageQueue myMq=new MessageQueue(@".\private$\ydzjgqueue"); myMq.Send(tempCmd.outputData,tempCmd.id.ToString(),System.Messaging.MessageQueueTransactionType.Automatic);配置文件: <add key="msmqPath" value=".\private$\ydzjgqueue"></add>接收消息: Dim MsgPath As String = System.Configuration.ConfigurationSettings.AppSettings("msmqPath") Dim MsgQue As MessageQueue = New MessageQueue(MsgPath)Dim Fmt As XmlMessageFormatter = CType(MsgQue.Formatter, XmlMessageFormatter)If (Not MessageQueue.Exists(MsgPath)) Then System.Messaging.MessageQueue.Create(MsgPath) End If''定义接收消息类型 Fmt.TargetTypeNames = New String() {"System.String,mscorlib"}'' 添加消息接受到时的处理 AddHandler MsgQue.ReceiveCompleted, New ReceiveCompletedEventHandler(AddressOf OnReceiveCompleted)''启动异步接收方式 MsgQue.BeginReceive()
发出消息:
MessageQueue myMq=new MessageQueue(@".\private$\ydzjgqueue");
myMq.Send(tempCmd.outputData,tempCmd.id.ToString(),System.Messaging.MessageQueueTransactionType.Automatic);配置文件:
<add key="msmqPath" value=".\private$\ydzjgqueue"></add>接收消息:
Dim MsgPath As String = System.Configuration.ConfigurationSettings.AppSettings("msmqPath")
Dim MsgQue As MessageQueue = New MessageQueue(MsgPath)Dim Fmt As XmlMessageFormatter = CType(MsgQue.Formatter, XmlMessageFormatter)If (Not MessageQueue.Exists(MsgPath)) Then
System.Messaging.MessageQueue.Create(MsgPath)
End If''定义接收消息类型
Fmt.TargetTypeNames = New String() {"System.String,mscorlib"}'' 添加消息接受到时的处理
AddHandler MsgQue.ReceiveCompleted, New ReceiveCompletedEventHandler(AddressOf OnReceiveCompleted)''启动异步接收方式
MsgQue.BeginReceive()