Reputation: 12553
I have an application that consumes messages from an MSMQ queue. The application uses MSMQ activation of a WCF service hosted in the IIS using AppFabric.
It is essential that the order of messages is preserved. But does MSMQ guarantee that the message order is preserved?
It seems to me, that if my application fails to process a message, e.g. because of a broken connection to the database, then the message is moved to the retry queue. This allows the application to receive new messages from the main queue until the original message is moved from the retry queue back to the main queue. After a certain number of retry intervals, the message is moved to the poison queue. But if the application processes new messages, then poison queue handling is simply not an option.
Thus the order of the messages has not been preserved.
Am I wrong in my understanding of how application errors are handled?
Can I setup the binding so that message order is preserved, also in the case when message processing temporarily fails?
Upvotes: 4
Views: 2182
Reputation: 1052
Pete,
A few tips from experience:
I highly recommend that you investigate the Saga Pattern, this is the answer to this type of problem, it is offered by products such as NServiceBus and MassTransit which will both remove the difficulty of having to manage MSMQ directly which you are stuck doing.
I understand that in your situation you may simply not have a choice and cannot "throw away" the model you are using, however it would be much more to your advantage to trigger a message and then on successful execution of this message (Saga), you could then insert the next message.
I hope this helps,
Upvotes: 3