我的消息没有到达目的地。我没有收到错误。即使在接收端打开了日志,它也不会显示在接收端的日志中。目标队列的权限设置为所有人完全控制。目标 msmq 服务的诊断显示 msmq ping 良好。本月早些时候,其他应用程序已成功写入此队列。它显示在我的日志中(发送端)。它没有出现在我端或接收端的死信或交易死信中。我仔细检查了队列名称。我没有发现谷歌点击或其他关于此的问题。我广泛搜索了“system.messaging”问题或“system.messaging”问题,以及其他一些更具体的搜索。
在这种特殊情况下,我使用的是 ActiveX 格式化程序。
Public Shared Sub Send(QueuePath As String, Label As String, Body As String, FormatterType As FormatterTypes)
Dim MessageQueue As MessageQueue
Dim MessageQueueTransaction As New MessageQueueTransaction
Try
If MessageQueue.Exists(QueuePath) Then
'creates an instance MessageQueue, which points
'to the already existing MessageQueue
MessageQueue = New MessageQueue(QueuePath)
If Not MessageQueue.CanWrite Then Exit Sub
Else
Throw New ArgumentException(String.Format("Queue does not exist '{0}'", QueuePath), "QueuePath")
End If
Dim Formatter As IMessageFormatter
Select Case FormatterType
Case FormatterTypes.ActiveX
Formatter = New ActiveXMessageFormatter
Case FormatterTypes.Binary
Formatter = New BinaryMessageFormatter
Case FormatterTypes.Xml
Formatter = New XmlMessageFormatter
End Select
Using Message As New Message(Body, Formatter)
Message.Label = Label
Message.AcknowledgeType = AcknowledgeTypes.FullReachQueue
Message.UseJournalQueue = True
Message.UseDeadLetterQueue = True
MessageQueueTransaction.Begin()
MessageQueue.Send(Message, MessageQueueTransaction)
MessageQueueTransaction.Commit()
End Using
Catch ex As MessageQueueException
MessageQueueTransaction.Abort()
Finally
MessageQueueTransaction.Dispose()
End Try
End Sub