Share via


MSMQTransaction.InitNew

 

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

(Introduced in MSMQ 2.0.) The InitNew method of the MSMQTransaction object initializes the MSMQTransaction object and associates it with an existing underlying transaction object, allowing Message Queuing to participate in the underlying transaction.

Sub InitNew( _  
  ByVal varTransaction As Variant _  
  )  

Parameters

varTransaction

[in] Existing underlying transaction object that supports an ITransaction interface (in C++, a reference to a VARIANT that specifies the underlying transaction object).

Return Values

This method has no return values.

Error Codes

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

Remarks

InitNew is used to initialize an MSMQTransaction object based on an existing non-Message Queuing underlying transaction. For example, you can associate an existing ADO transaction with an MSMQTransaction object, allowing you to perform Message Queuing operations within the ADO transaction. Subsequent calls to commit or abort the transaction would be made using MSMQTransaction.Commit and MSMQTransaction.Abort.

Note

MSMQTransaction objects are created and associated with an underlying transaction using MSMQCoordinatedTransactionDispenser.BeginTransaction or MSMQTransactionDispenser.BeginTransaction.

An MSMQTransaction object can be associated with only one underlying transaction object. InitNew will fail if the MSMQTransaction object is already associated with another underlying transaction object. For example:

  • InitNew will fail if it is called twice on the same MSMQTransaction object.

  • InitNew will fail if MSMQTransactionDispenser.BeginTransaction or MSMQCoordinatedTransactionDispenser.BeginTransaction is called to obtain the MSMQTransaction object before the InitNew method is called.

In C++ COM applications, you must use a smart pointer to the IMSMQTransaction2 or IMSMQTransaction3 interface to expose the InitNew method.

Requirements

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

Windows 95/98/Me: Unsupported.

Header: Declared in Mqoai.h.

Library: Use Mqoa.lib.

See Also

MSMQCoordinatedTransactionDispenser.BeginTransaction
MSMQTransaction
MSMQTransaction.Abort
MSMQTransaction.Commit
MSMQTransactionDispenser.BeginTransaction