サーバー 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」に変更すると、セットアップしたローカル トランザクション キューに送信されます。キュー自体のセットアップは同じです (同じ手順を実行して、localhost キューと THOR キューの両方を作成しました)。