问题
I read about MessageQueueTransaction in MSDN, but I can't find anything about timeouts. What happens if the Commit or Abort just never get called ? Is there some sort of timeout for a transaction between the time it's open and it's release ?
回答1:
This is an internal transaction so doesn't involve MSDTC (which does have a timeout). I believe that the transaction will exist until your application calls commit or abort. If the application fails or exits without calling either then I would expect MSMQ to abort the transaction for you.
Do you have a specific problem or just curious?
Cheers
John Breakwell
回答2:
Thanks John ! I just made a WCF service that receive messages from MSMQ and transmit them back to the remote client. The client can request x number of messages.
The client first call the service to start a transaction. The service stacks it in a collection with a GUID. This guid is sent back to the client and the client will use it for all other call to the service. Therefore, the service can find the corresponding transaction and use it with the Receive().
After the client has done all it's work, it calls a Terminate(bool commit) method with the GUID that calls the Commit or Abort on the transaction. But what append if the Commit or Abort never gets called because the client has crashed or the network broke ? That's my concern...
I basicaly did this because MSMQ 3 doesn't support remote transaction (only MSMQ 4).
回答3:
The answer lies within the internal ACK messaging of MSMQ itself. So to answer your question, undoubtedly if you do NOT Commit or Abort a Message which uses a Transaction after you retrieve it, it will in fact rollback. This is how power-loss events are handled, etc.
When sending messages within a transaction the same is true except dependent on timeout parameters, the failure of the recipient to acknowledge receipt of the message may ultimately cause the letter to go to the Dead Letter Queue. You can always reprocess these - but whether you want to or not depends on the type of system you are building.
---- Per MSDN https://msdn.microsoft.com/en-us/library/ms699870(v=vs.85).aspx
Additional information about the ultimate outcome of message sending operations becomes available when applications request positive and negative acknowledgment messages. For more information on requesting acknowledgment messages, see Acknowledgment Messages.
https://msdn.microsoft.com/en-us/library/ms707129(v=vs.85).aspx
Hope that helps.
来源:https://stackoverflow.com/questions/5903538/messagequeuetransaction-timeout