Internal transactions involve only Message Queuing resources and are managed entirely from within Message Queuing. You use the following language elements to indicate an internal transaction:
Element | Used to |
---|---|
BeginTransaction | Indicate the start of a transaction that consists of one or more messages and operations |
CommitTransaction | Used to commit the transaction if all of the message operations it contained were performed successfully |
RollbackTransaction | Used to undo all of the previously performed messaging operations if one of the operations in the transaction cannot be completed successfully. |
Note A disconnected or full queue is not considered a failure. You decide in your code for the RollbackTransaction method what constitutes a rollback.
To send messages within an internal transaction
Your code might look like this:
[Visual Basic] Try mq.BeginTransaction messageA = mq.Send(1000) messageB = mq.Send(1000) mq.CommitTransaction Catch mq.RollbackTransaction End Try [C#] try { mq.BeginTransaction(); messageA = mq.Send(1000); messageB = mq.Send(1000); mq.CommitTransaction(); } catch { mq.RollbackTransaction(); }
Transactional Message Processing | Creating a Transactional Queue | Creating MessageQueue Components | Sending and Serializing Messages