MSMQTransactionDispenser.BeginTransaction

 

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 MSMQTransactionDispenser object initiates a new Message Queuing internal transaction and returns an MSMQTransaction object that represents the new underlying transaction object and can be used to send or retrieve messages within the internal transaction.

Function BeginTransaction
()  

Parameters

This method has no parameters.

Return Values

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

Error Codes

The following error codes can be returned by this method.

MQ_OK (0L)

Indicates success.

MQ_ERROR_TRANSACTION_USAGE (0xC00E0050L)

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.

For a complete list of error and information codes, see Message Queuing Error and Information Codes.

Remarks

The MSMQTransaction object returned by BeginTransaction must be associated with all transactional queues and messages associated with the current internal transaction. However, this does not mean that a transactional queue associated with this transaction cannot be used by other transactions. A single transactional queue can be associated with any number of transactions. For information on the transaction model used by Message Queuing, see Transactions.

Equivalent API Function

When using API functions, call MQBeginTransaction to create a Message Queuing internal transaction object that can be used to send messages to a queue or read messages from a queue.

Example Code

The following examples are included in Using Message Queuing.

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

 Visual Basic 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 Mqoai.h.

Library: Use Mqoa.lib.

See Also

MSMQTransaction
MSMQTransactionDispenser