接收消息:
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)