Important: |
---|
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
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 IsTransactionalparameter of MSMQQueueInfo.Createmust be set to True when the queue is created.
Specify Transaction type
The Transactionparameter of MSMQMessage.Send, MSMQQueue.Receive, and MSMQQueue.ReceiveCurrentspecifies 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.Priorityto "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.MaxTimeToReceiveand MSMQMessage.MaxTimeToReachQueuevalue 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 |