Reputation: 927
Having simple code that peeks message from queue
message = myQueue.Peek(TimeOutForPeek);
On the other side message are simply sent to queue:
sendQueue.Send(message);
If myQueue is transactional, then everything works ok. But if not, after certain time of running I got exception (see below) and processing stops.
System.Messaging.MessageQueueException (0x80004005): Operation was cancelled before it could be completed. at System.Messaging.MessageQueue.ReceiveCurrent(TimeSpan timeout, Int32 action, CursorHandle cursor, MessagePropertyFilter filter, MessageQueueTransaction internalTransaction, MessageQueueTransactionType transactionType) at System.Messaging.MessageQueue.Peek(TimeSpan timeout)
What may cause such difference and how to deal with such failures? I am not very familiar with MSMQ, any help will be appreciated.
Upvotes: 2
Views: 1638
Reputation: 4632
I can't quite put the finger on it, but at least the error message states obviously that there is a long running process that does not finish within a certain time.
As you stated in your comment above that there are 3000-5000 messages received within a short time period I suppose that the receiving system is still busy processing them when the error occurs and not return soon enough to read the next message(s) before a timeout occurs.
Possibly you are reaching your system's resource limits?
Your description would fit... Like, the machine is receiving so-and-so-many messages but cannot handle them quick enough before the next messages arrive.
If it works for transactional queues, I suspect that the MSMQ resouces handling differs in both scenarios.
Have a look at John Breakwell's very detailed blog post Insufficient Resources? Run away, run away! and check if there is something you can find helpful. There is A LOT of stuff in there.
Other thought:
If your receiving end is single threaded, consider processing the messages in parallel if you are not already doing so (if applicable for your scenario). This might help getting the messages out of the queue faster before the new messages arrive.
Upvotes: 2