我在THOR服务器上建立了一个事务性MSMQ队列。我能够使用以下代码从工作站向该队列发布消息:
var queue = new MessageQueue("FormatName:Direct=OS:thor\\private\\myqueue");
using (var tx = new MessageQueueTransaction())
{
tx.Begin();
queue.Send("test", tx);
tx.Commit();
}
然而,当我尝试使用WCF连接时,我的消息从未出现在队列中。这是我正在使用的配置:
<system.serviceModel>
<bindings>
<netMsmqBinding>
<binding name="ClientNewsFeedServiceBinding" durable="true" exactlyOnce="true">
<security mode="None" />
</binding>
</netMsmqBinding>
</bindings>
<client>
<!-- NewsFeed Service -->
<endpoint name="INewsFeedService"
address="net.msmq://thor/private/myqueue"
binding="netMsmqBinding"
bindingConfiguration="ClientNewsFeedServiceBinding"
contract="Service.Contract.INewsFeedService" />
</client>
</system.serviceModel>
代码如下:
using (var tx = new TransactionScope())
{
var cf = new ChannelFactory<INewsFeedService>("INewsFeedService");
var service = cf.CreateChannel();
service.TestMessage("test");
((IChannel)service).Close();
tx.Complete();
}
我没有收到任何异常信息,但是在THOR上没有发布任何消息。有什么想法吗?由于它只是静默失败,所以我甚至不知道如何进行调试。
更新: 如果我将我的MSMQ URI更改为"net.msmq://localhost/private/myqueue",那么它将发布到我设置的本地事务队列。队列本身的设置是相同的(也就是说,我执行了创建本地主机和THOR队列的相同步骤)。