MSMQ activities overview
This section contains Workflow activities for operations on Microsoft message queues (MSMQ).
Like many other listener/reader activities, an MSMQ listener creates an ambient listener which runs in the background and continuously feeds the Get Next MSMQ Message activity with new messages. It is possible to run multiple Get Next MSMQ Message activities in parallel, but each message can only be delivered to one activity (by a FIFO (first-in first out) order).
To listen to messages from an MSMQ, a configuration must first be created (see Create MSMQ Listener Configuration). The configuration specifies which queue should be monitored along with some other properties, for example how messages should be received, whether other processes will have access to the queue while it is being monitored, and what message properties are retrieved for the Get Next MSMQ Message activity.
When the configuration has been created, it can be passed on to the Start MSMQ Listener activity which returns an ID to the listener which is now idle in the background. The listener will not actually start listening to the queue until at least one Get Next MSMQ Message activity has been started. The returned ID should be sent to any subsequent activities that refer to this listener.
The next step is to invoke a Get Next MSMQ Message activity, passing the ID to the listener and causing it to start receiving messages from the queue. Get Next MSMQ Message will block the execution and wait for a message to become available on the queue, or for a timeout to occur.
The Get Next MSMQ Message activity will also prevent a system shutdown from terminating the Workflow, unless the "Is implicitly cancellable" property is set to 'True' or the activity is contained within a Cancellable Scope.
Once a message has been received, the activity returns the received message and execution is resumed with the next activity. Get Next MSMQ Message can be invoked as many times as desired (using the same listener ID), and can even be invoked in parallel.
To stop listening for messages on the queue, the Stop MSMQ Listener activity is invoked using the same ID received from the Start MSMQ Listener activity. Any Get MSMQ Message activities that are still running and blocking in the current Workflow will throw an exception.
The template MSMQ Listener Template contains the above activities in a looping sequence that keeps listening for new messages and performs an action on each one as it arrives. If only a single message is to be retrieved, the Get MSMQ Message activity can be used instead. This activity simply retrieves a single message from a specified queue, and is easier to use for scenarios where only a single message is desired. Note that Get MSMQ Message is less efficient to use if you want to receive multiple messages from the same queue with the same options after one another.
For more information regarding MSMQ see Microsoft help topic on MSMQ.
Activities
| Icon | Activity | Description |
|---|---|---|
| Create and Send MSMQ Message | Creates a new MSMQ message and sends the message to a destination queue. | |
| Create MSMQ Listener | Configuration Creates a configuration object that can be used to configure MSMQ listener activities. | |
| Create MSMQ Message | Creates a new instance of an MSMQ message. | |
| Get MSMQ Message | Reads an MSMQ message from a queue, optionally matching a specified message ID or correlation ID and optionally removing the message from the queue. | |
| Get Next MSMQ Message | Gets the next available MSMQ message from an active MSMQ listener. | |
| MSMQ Listener Template | Creates the activities needed to process MSMQ messages from a queue. | |
| Send MSMQ Message | Sends a message to an MSMQ queue. | |
| Start MSMQ Listener | Starts a new MSMQ listener subscription returning the identity of the listener. Identity is used when reading messages. | |
| Stop MSMQ Listener | Stops an active MSMQ listener. The listener identity will no longer be valid after completion of this activity. |