Share via


Sending a Single-Message Transaction (COM)

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

Message Queuing provides a single-message transaction that implicitly uses the internal transaction support provided by Message Queuing.

The benefits of this type of transaction include the following:

  • Greater speed, compared to using an external transaction coordinator.
  • Simplified application code.
  • Exactly once delivery without the need to coordinate other activities within a single transaction.

The only difference between sending a non-transactional message and using a single-message transaction is that the destination queue must be a transactional queue, and the Transaction parameter of MSMQMessage.Send must be set to MQ_SINGLE_MESSAGE.

Note

Each Message Queuing message can have no more than 4 MB of data.

To send a single-message transaction

  1. Declare the objects needed to send a message.

    This example uses a MSMQQueueInfo, MSMQQueue, and MSMQMessage object.

  2. Call MSMQQueueInfo.Open to open the transactional queue with send access.

  3. Call MSMQMessage.Send to send the message.

    In this example, the Transaction parameter is set to MQ_SINGLE_MESSAGE.

  4. Call MSMQQueue.Close to close the queue.

See Also

Concepts

MSMQ COM Support
Using the COM Components
MSMQ Security

Other Resources

Message Queuing