我已经创建了一个WCF服务来向MSMQ发送消息,我可以让它运行它看起来像是发送了消息但是在查看队列时它不在那里。我已经验证并且队列不是事务性队列。安全是开放的,所以每个人都可以发送消息,但我想知道是否有其他地方设置安全性?这是我正在使用的代码。
Dim mq As MessageQueue
Dim msg As Message
Dim queueName As String = "webdevbvm.labsafety.com\emailsubscriptions"
Try
msg = New Message("Test")
msg.Priority = MessagePriority.Highest
If (MessageQueue.Exists(queueName)) Then
mq = New MessageQueue(queueName)
msg.ResponseQueue = mq
msg.UseJournalQueue = True
msg.Label = "Test Message"
msg.Body = "This is only a test"
mq.Send(msg)
Console.WriteLine("Message sent.")
End If
Catch ex As MessageQueueException
Console.WriteLine("MSMQ Error: " + ex.ToString())
Catch ex As Exception
Console.WriteLine("Error: " + ex.ToString())
Finally
mq.Close()
End Try
我没有错误,但我确实从运行程序的机器上看到了传出队列中的消息。它显示队列存在,如果我将队列名称更改为不存在的队列名称,则不会进入IF语句,因此我知道它看到队列只是没有发送文件。如果它有助于我在笔记本电脑上本地运行该程序,那么它发送的队列也在Windows 2003服务器上。
答案 0 :(得分:2)
对我来说,这看起来不像是WCF服务 - 似乎您正在使用基础System.Net.Messaging
API向您的队列发送消息....
查看其中的一些链接,了解如何使用WCF向MSMQ发送消息:
马克
答案 1 :(得分:1)
感谢marc的回复,但我想出了需要做些什么。基本上我使用了错误的队列名称。我在队列名称前面没有“FormatName:DIRECT = OS:”。有一次,我说它很好。再次感谢。
罗伯特