Share via


Programming Considerations when Using Transactions (COM) (Windows Embedded CE 6.0)

1/6/2010

Here is an overview of issues that you should consider when building your application.

Creating a Transactional Queue

Messages sent within a transaction must be sent to a transactional queue.

To create a transactional queue, the IsTransactional parameter of MSMQQueueInfo.Create must be set to True when the queue is created.

Specify Transaction type

The Transaction parameter of MSMQMessage.Send, MSMQQueue.Receive, and MSMQQueue.ReceiveCurrent specifies the transaction type.

  • MS DTC External Transaction
    Set Transaction to the transaction object returned by MSMQCoordinatedTransactionDispenser.BeginTransaction.
  • Message Queuing Internal Transaction
    Set Transaction to the transaction object returned by MSMQTransactionDispenser.BeginTransaction.
  • Single Message Transaction
    Set Transaction to MQ_SINGLE_MESSAGE.
  • MTS Transaction
    Set Transaction to MQ_MTS_TRANSACTION. This is the default setting for this parameter.
  • XA-compliant Transaction
    Set Transaction to MQ_XA_TRANSACTION.

Committing and Aborting the transaction

Messages are not sent or retrieved until the application commits to the transaction. When the transaction is aborted, all changes to the queue are rolled back to their original state.

Sending messages

Transactional messages must be sent to transactional queues and non-transactional messages must be sent to non-transactional queues.

Message priority levels

The priority level of all transactional messages is set to 0. Message Queuing sets the value of MSMQMessage.Priority to "0" regardless of what the sending application may specify.

Message timers

When sending multiple messages, Message Queuing sets the time-to-be-received and time-to-reach-queue timers of all messages to the MSMQMessage.MaxTimeToReceive and MSMQMessage.MaxTimeToReachQueue value specified by the first transactional message sent within the transaction.

MTS Transactions

Message Queuing can automatically detect and become part of an MTS transaction. The MQ_MTS_TRANSACTION constant is the default value of the Transaction parameter of MSMQMessage.Send, MSMQQueue.Receive, and MSMQQueue.ReceiveCurrent.

The current MTS context may or may not be transactional. Before using the MTS context, always verify that it is transaction.

For examples on See

Using a single-message transaction to send a message

Sending a Single-Message Transaction (COM)

See Also

Concepts

Using Transactions (COM)
MSMQ COM Support
Using the COM Components
MSMQ Security

Other Resources

Message Queuing