The Abort method terminates the transaction associated with the MSMQTransaction object.
object.Abort ([fRetaining][, fAsync])
Syntax Element | Description |
object | Transaction (MSMQTransaction) object that identifies the transaction. |
fRetaining | Optional. Boolean. |
fAsync | Optional. Boolean. |
After an abort, all actions taken on the queue are rolled back. For example, if a message is sent to a queue and the transaction is aborted, the messages are not sent to the queue.
Abort is a wrapper for lTransaction::Abort. For information on lTransaction::Abort, see the Microsoft Platform SDK.)
This example starts a transaction, sends two messages, and then terminates the transaction.
Dim xdispenser as New MSMQCoordinatedTransactionDispenser Dim xact as MSMQTransaction Dim qSend as MSMQQueue Dim msg1 as New MSMQMessage Dim msg2 as New MSMQMessage Set xact = xdispenser.BeginTransaction Set qSend = qinfo.Open(MQ_SEND_ACCESS, MQ_DENY_NONE) msg1.Label = "MyTransaction message" msg1.Body = "Message 1 Body" msg1.Send qSend, xact 'Associates send with xact. msg2.Label = "MyTransaction message" msg2.Body = "Message 2 Body" msg2.Send qSend, xact 'Associates send with xact. xact.Abort 'Aborts transaction.
BeginTransaction, Body, Label, Open, Send