Remote receive from MSMQ queue

1 day ago 3
ARTICLE AD BOX

We were forced to change from receiving from a local server to a remote one using MSDTC (a very legacy 3.5 framework). Before this, we used the MessageQueueTransaction class with local receiving, and it worked well. But after changing the host to remote in the queues, a problem occurred - messages did not go into our service. So we decided to change MessageQueueTransaction to TransactionScope:

using (var scope = new TransactionScope(TransactionScopeOption.Required, TimeSpan.FromSeconds(120))) { msg = mq.Receive(TimeSpan.FromSeconds(60), MessageQueueTransactionType.Automatic); scope.Complete(); }

It worked fine until we changed one very high-traffic queue to remote. It worked for a few hours and then all remote queues went down with these errors from MessageQueueException:

MQErrorCode=-2147023170, NativeErrorCode=-2147467259, Message= (at first)
MQErrorCode=-2147023174, NativeErrorCode=-2147467259, Message= (at second)
MQErrorCode=-2147024890, NativeErrorCode=-2147467259, Message= (and then, this one was a lot)

(Yes, there are no messages being thrown, only error codes)

We have the same problem with the async variation (BeginPeek + Receive), but here the exception always comes exactly after 6 minutes (no more, no less, exactly 6 minutes!).

//behind in other code: this.MQ.PeekCompleted += new PeekCompletedEventHandler(AsyncMethod); this.mq.BeginPeek(); // private void AsyncMethod() { mq.EndPeek(asyncRes.AsyncResult); try { if (this.MQTran) { using (var scope = new TransactionScope(TransactionScopeOption.Required, TimeSpan.FromSeconds(60))) { msg = mq.Receive(TimeSpan.FromSeconds(30), MessageQueueTransactionType.Automatic); scope.Complete(); } } } catch { // logging here } finally { mq.BeginPeek(); } }

Why does this happen? I know that receiving from a remote queue is a very bad pattern, but I have to do this. Is there something I can do with this code? Maybe there's nothing to do, and one variation is simply to reload the MessageQueue when this exception occurs? Or which timeouts (maybe subnet firewalls, etc) should I check?

The MSMQ server with receive queues and our service server are placed on different subnets, windows server 2019+, if it matters.

Read Entire Article