What happens when my application consumes an MSMQ message but then crashes?

If I ask Bob to get me a sandwich, and Bob says, "Okay," but then he gets hit by a bus on the way from the store, I'll never get my sandwich - and I don't know I'm "Not going to get my sandwich!" I don't say to anyone, "hey, I'm hungry!"

Is there a way to deal with this issue in MSMQ? Can I reserve the message so that it doesn't get passed on to anyone else, but doesn't consume it, so that I can queue it back later if I choke it?

I don't even know what you call it .: |

Clarification: I am using a transactional queue. But if a consumer receives a message (and the message is deleted), what happens when that consumer doesn't do what it asks for? The only option is for the consumer to put it back in the queue?

+3


source to share


2 answers


So, I finally found the answer: you can use transactions on a call Receive()

as much as you can on a call Send()

. You can then rollback the transaction and it will be rolled back, leaving a message in the queue (assuming, of course, that you are using a transactional queue).

I actually found this answer on StackOverflow ( MSMQ get rolling back the transaction without making the message available again ), but the question was asked completely different so it was all easy to find.



I'm leaving this question just in case the semantics more closely match another google search.

+1


source


This is called "exact semantic semantics" and is quite difficult to achieve for any distributed process; this is not the case for MSMQ.

The typical way to handle it is by using a sliding delivery window; Tell Bob, "Pass me the sandwich before 1:00 or forget about it." Then if you don't have a 1 million sandwich, tell Claire, "Pass me the sandwich by 2pm or forget about it." If Bob keeps back with your sandwich and he sees it after 1pm, he has to decide what to do with the sandwich, but he can't give it to you.



There is actually quite a lot of research on this topic; Google "exactly once". I see Microsoft claims MSMQ supports it via MQMgmtGetInfo .

+1


source







All Articles