Applies To: Windows 10, Windows 7, Windows 8, Windows 8.1, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2, Windows Server Technical Preview, Windows Vista

The BeginTransaction method of the MSMQCoordinatedTransactionDispenser object initiates an MS DTC external transaction by creating a new MS DTC transaction object. It returns an MSMQTransaction object that represents the new underlying transaction object and is used to send or retrieve messages during the transaction.

Function BeginTransaction
() As MSMQTransaction  


This method has no parameters.

Return Values

An MSMQTransaction object that identifies the underlying MS DTC transaction object (in C++, a smart pointer to the IMSMQTransaction interface).

Error Codes

This method also returns one of the following error codes:

MQ_OK (0L)

Indicates success.


While reading messages, one of the following actions were attempted within the context of a transaction:

An attempt was made to open a remote queue for read access.

An attempt was made to read a message from a nontransactional queue.

An attempt was made to read a message using a callback or overlap function.


The MSMQTransaction object returned by BeginTransaction must be associated with all transactional messages sent or read within this transaction. For information on MS DTC external transaction, see MS DTC External Transactions.

For information on the transaction model used by Message Queuing and additional transaction types, see Transactions.

Example Code

The following code fragment shows how to initiate an MS DTC external transaction by creating a new MS DTC transaction object.

Dim xdisper As New MSMQCoordinatedTransactionDispenser  
Dim xact As MSMQTransaction  
Set xact = xdisper.BeginTransaction  

The following example is included in Using Message Queuing.

For an example of See
Sending messages using an MS DTC external transaction C/C++ Code Example: Sending a Message Using an MS DTC External Transaction


Windows NT/2000/XP: Included in Windows NT 4.0 SP3 and later.

Windows 95/98/Me: Included in Windows 95 and later.

Header: Declared in Mqoai.h.

Library: Use Mqoa.lib

See Also