Share via


MQBeginTransaction

 

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 MQBeginTransaction function creates a Message Queuing internal transaction object that can be used to send messages to a queue or read messages from a queue.

HRESULT APIENTRY MQBeginTransaction(  
  ITransaction ** ppTransaction    
);  

Parameters

ppTransaction

[out] Pointer to a pointer to the ITransaction interface for the new transaction object.

Return Values

MQ_OK

Indicates success.

MQ_ERROR_INSUFFICIENT_RESOURCES (0xC00E0027)

There are no resources to create a new transaction.

MQ_ERROR_TRANSACTION_ENLIST (0xC00E0058)

Message Queuing could not enlist in the transaction.

Remarks

The pointer returned by MQBeginTransaction can be used to set the pTransaction parameter of MQSendMessage or MQReceiveMessage.

When using an explicit internal transaction, make sure that the transact.h header file is included before mq.h. Transact.h provides the transaction object.

Equivalent COM Method

When using COM components, you can initiate a new Message Queuing internal transaction by calling the MSMQTransactionDispenser.BeginTransaction method, which returns a COM object that represents the new underlying transaction object.

For information on See
Explicit internal transactions Message Queuing Internal Transactions
Implicit internal transactions Single-Message Transactions

Example Code

The following code example is included in Using Message Queuing.

For a complete example of See
Sending a message using an internal transaction C/C++ Code Example: Sending a Message Using an Internal Transaction

Requirements

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 Mq.h.

Library: Use Mqrt.lib.

See Also

Message Queuing Functions
MQReceiveMessage
MQSendMessage