With recoverable messages, it is not guaranteed that the messages will arrive in order and just once. Failures on the network can cause messages to arrive multiple times; this happens also if both the sender and receiver have multiple network protocols installed that are used by Message Queuing.
- Messages arrive in the same order they have been sent.
- Messages arrive only once.
With transactional queues, a single transaction doesn’t span the sending and receiving of messages. The nature of Message Queuing is that the’ time between send and receive can be quite long. In contrast, transactions should be short. With Message Queuing, the first transaction is used to send the message into the queue, the second transaction forwards the message on the network, and.the third transaction is used to receive the messages.
The next example shows how to create a transactional message queue and how to send messages using a
A transactional message queue is created by passing true with the second parameter of the MessageQueue Create() method.
If you would like to write multiple messages to a queue within a single transaction, you have to instantiate a MessageQueueTransaction object and invoke the Begin() method. When you are finished with sending all messages that belong to the transaction, the Commit() method of the MessageQueueTransaction object must be called. To cancel a transaction (and have no messages written to the queue, the Abort() method must-be called, as you can see within the catch block: