Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does MSMQ Transactional Message Delivery work?

Tags:

msmq

Just wanted to get confirmation on how sending messages to remote transactional message queues works.

Suppose I have a two machines, A and B.

Machine A has a transactional queue that is used for receiving messages. A windows service monitors this queue and does something with the data (persists it to a SQL Server). Machine B is running an application that needs to write to the queue on Machine A.

A few questions:

  1. When sending the message, is a local copy created on Machine B, before it gets delivered to machine A?
    a. If so, is this behavior by default, or does it only occur when the "IsRecoverable" property is sent?
    b. Does the fact that the queue is transactional have any effect on this behavior?

  2. Since I'm using a transactional queue, where is the data once the transaction commits? a. Is it sitting locally, waiting for the msmq service to deliver the message to the remote queue?
    b. Or Is the message sitting in the queue on the remote machine?

I'm having trouble interpreting the documentation. In some places I see that the store and forward behavior is described, but I'm having trouble understanding whether that is the default behavior with transactional queues or if I need to do something explicitly to get that going.

like image 484
Kartik Avatar asked Oct 04 '11 16:10

Kartik


People also ask

What is MSMQ transactional?

In this article Sending and receiving applications can indicate that they want to send or retrieve messages within the context of a transaction. Sending or retrieving messages within the context of a transaction is referred to as transactional messaging.

Can we do transactions using MSMQ?

For the MSMQ adapter, a transaction extends from the BizTalk MessageBox database to the local Message Queuing queue even if you are using a remote queue. You can use transactions on both send and receive with the MSMQ adapter.

How does MSMQ queue work?

Message Queuing (MSMQ) technology enables applications running at different times to communicate across heterogeneous networks and systems that may be temporarily offline. Applications send messages to queues and read messages from queues.


1 Answers

The main thing to understand about transactional MSMQ is that there are actually 3 distinct transactions involved in a transactional transmission of a message to a remote queue.

  1. The sender writes the message to a local temporary queue.
  2. The queue manager on the senders machine transmits the message across the wire to the queue manager on the recipient machine.
  3. The receiver service processes the queue message and then removes the message from the queue.

So in answer to your questions:

When sending the message, is a local copy created on Machine B, before it gets delivered to machine A?

Yes

If so, is this behavior by default, or does it only occur when the "IsRecoverable" property is sent?

By default. This is what is known as store and forward.

Does the fact that the queue is transactional have any effect on this behavior?

No except for when there is a failure.

Since I'm using a transactional queue, where is the data once the transaction commits?

It depends which transaction you mean (see above)

Is it sitting locally, waiting for the msmq service to deliver the message to the remote queue?

Only if the remote queue is not available.

Or Is the message sitting in the queue on the remote machine?

If the receiver service fails to process the message succesfully (there is an exception in the handler) the message will stay on the remote queue.

like image 156
tom redfern Avatar answered Oct 05 '22 13:10

tom redfern