MSMQ (Microsoft Message Queuing) is a messaging protocol that allows applications running on separate servers/processes to communicate in a fail-safe manner. A queue is a temporary storage location from which messages can be sent and received reliably, as and when conditions permit. This enables communication across networks and between computers which may not always be connected. MSMQ activities supply reliable and secure automated message delivery and retrieval, efficient routing, and priority-based messaging. A user-friendly interface contains a variety of activities that allow you to create, send, retrieve, clear, delete, or wait for MSMQ messages on a local or remote machine.
IMPORTANT: MSMQ must be installed on the system (local or remote) in order to perform MSMQ actions. MSMQ is bundled with Windows 2000, Windows XP (Excluding Home Edition), Windows Server 2003 and Vista operating systems, however, they are not installed by default.
To install Message Queuing on a computer running Windows 2000, Windows XP, or Windows Server 2003, administrators use the Add/Remove Windows Components feature of Add or Remove Programs in the Windows Control Panel. No other software is required. To install Message Queuing on a computer running Windows Vista or Windows 7, administrators use the Turn Windows Features On or Off feature in the Control Panel. Also refer to MSMQ Overview and Installation.
Declaration
<AMMSMQ QUEUENAME="myQueue" PRIVATE="YES" RESULTDATASET="theDataset" />
See Also: Loop Dataset Action
In the Activity to perform box, select an activity, then configure the properties for that activity. The available properties depend on the activity selected.
To set MSMQ properties
In the Available Actions pane, open the Network folder and double-click the MSMQ action or drag it into the Steps pane.
On the Properties tab, select an Activity to perform.
Specify the properties that appear, depending on the activity selected.
To set the Description tab properties, refer to Description Tab Options.
To set the Error Causes and On Error tab properties, refer to Step Error Handling.
When finished, click OK to save settings and close the properties dialog box.
Available Activities
The following table briefly describes the available activities for this action as specified in the Activity to perform box.
Activity |
Description |
Declaration |
Examples |
Clear Queue |
Clears existing messages from the specified queue. The Retrieve Message and Wait for Message activities can also be used to remove a message from the queue. |
<AMMSMQ ACTION="clear" REMOTEMACHINE="text" QUEUENAME="text" /> |
This example clears a queue named "VMWINVX64\private$\myQueue" on the local computer. <AMMSMQ ACTION="clear" QUEUENAME="VMWINVX64\private$\myQueue" /> |
Create Queue |
Creates a message queue with the specified name on the local or remote computer and populates a dataset with information about the newly created queue. |
<AMMSMQ REMOTEMACHINE="text" QUEUENAME="text" TRANSACTIONAL="YES/NO" RESULTDATASET="text (dataset name)" /> |
This example creates a private queue named "myQueue" on the local computer. Queue information is stored in a dataset named "myDataset". <AMMSMQ QUEUENAME="myQueue" PRIVATE="YES" RESULTDATASET="myDataset" /> |
Delete Queue |
Deletes the specified message queue located locally or on a remote computer. |
<AMMSMQ ACTION="delete" QUEUENAME="text" /> |
This example delete's the queue "VMWINVX64\private$\myQueue" located on the local computer. <AMMSMQ ACTION="delete" QUEUENAME="VMWINVX64\private$\myQueue" /> |
Retrieve Message |
Retrieves a message from the specified queue. A dataset is populated with specific information about the message and a variable is populated with the message text. |
<AMMSMQ ACTION="retrieve_message" REMOTEMACHINE="text" QUEUENAME="text" RESULTDATASET="text" RETRIEVEBY="text (options)" MESSAGEID="text" MESSAGEFILE="text" OVERWRITEFILE="YES/NO" REMOVEMESSAGE="YES/NO" /> |
This example retrieves the first message from queue "vmwinvx64\Private$\myQueue" on the local computer and removes the message from the queue upon arrival. Queue information is stored in dataset "theMessageInfo". The message body is stored in variable "theMessageText". <AMMSMQ ACTION="retrieve_message" QUEUENAME="vmwinvx64\Private$\myQueue" RESULTDATASET="theMessageInfo" RESULTVARIABLE="theMessageText" ENCODING="ASCII" REMOVEMESSAGE="YES" /> This example retrieves a message by lookup ID from queue "vmwinvx64\myQueue" on a remote computer. Queue information is stored in dataset "theMessageInfo". The message body is stored in file ""c:\temp\theMessage.txt". <AMMSMQ ACTION="retrieve_message" REMOTEMACHINE="computername" QUEUENAME="vmwinvx64\myQueue" RESULTDATASET="theMessageInfo" RETRIEVEBY="LookupID" MESSAGEID="1234567890" MESSAGEFILE="c:\temp\theMessage.txt" OVERWRITEFILE="YES" REMOVEMESSAGE="YES" /> |
Send Message |
Sends a message to the specified queue located locally or on a remote computer. |
<AMMSMQ ACTION="send_message" REMOTEMACHINE="text" QUEUENAME="text" MESSAGELABEL="text" MESSAGETEXT="text" /> |
This example sends a message to queue "vmwinvx64\Private$\myQueue" on the local computer with message label "myMessage". <AMMSMQ ACTION="send_message" QUEUENAME="vmwinvx64\Private$\myQueue" MESSAGELABEL="myMessage" MESSAGETEXT="This is the message. " ENCODING="ASCII" TRANSACTIONAL="YES" /> |
Wait for Message |
Suspends task execution and waits for a specified message to exist in the selected queue. Upon arrival, the message is retrieved and task execution continues. A dataset is populated with specific information about the message and a variable is populated with the message text. The Retrieve Message activity throws an error if the specified message does not exist in the queue. Use this activity in place of the Retrieve Message activity to allow the task to wait at the current step until a message arrives. |
<AMMSMQ ACTION="wait_message" REMOTEMACHINE="text" QUEUENAME="text" RESULTDATASET="text" MESSAGELABEL="text" TIMEOUT="number" RESULTVARIABLE="text" ENCODING="text (options)" REMOVEMESSAGE="YES/NO" /> |
This example waits for the message labeled "Message10" from queue "vmwinvx64\Private$\myQueue" on the local computer and removes the message from the queue upon arrival. Queue information is stored in dataset "theMessageInfo". The message body is stored in variable "theMessageText". <AMMSMQ ACTION="wait_message" QUEUENAME="VMWINVX64\private$\myQueue" RESULTDATASET="theMessageInfo" MESSAGELABEL="Message10" TIMEOUT="7" RESULTVARIABLE="theMessageText" REMOVEMESSAGE="YES" /> |
General Properties
Property |
Type |
Required |
Default |
Markup |
Description |
Local Machine |
Yes/No |
No |
Enabled |
NULL |
If enabled, specifies that this activity will be performed on the local machine. If selected, the Remote Machine parameter is ignored. This parameter is enabled by default. |
Remote Machine |
Text |
No |
(Empty) |
REMOTEMACHINE="hostname" |
If enabled, specifies the host name or IP address of the remote machine that this activity will be performed on. If this parameter is enabled, the Local Machine parameter is ignored. |
Message Queue Name |
Text |
Yes |
(Empty) |
QUEUENAME="ComputerName\QueueName" |
The name of the message queue to create. The message queue name consists of the compute name, an optional PRIVATE$ keyword that indicates whether it is a private queue and the name of the queue. Public queue example: ComputerName\QueueName Private queue example: ComputerName\PRIVATE$\QueueName |
Message Label |
Text |
Yes |
(Empty) |
LABEL="theCoolMessage" |
The label of the message to send. This label can be used in the Wait for Message activity to allow for a specific message to wait for. |
Message Text |
Text |
No |
(Empty) |
MESSAGETEXT="This is the message" |
If enabled, specified the text message to send. If this parameter is enabled, the Message File parameter is ignored. |
Message Body Type |
Text (options) |
No |
Text |
NULL |
Indicates whether the message contents should be retrieved as text populated into a variable or saved to a specific text file. Different parameters become active depending on which option is selected. The available options are:
|
Retrieve message by |
Text (options) |
No |
First |
RETRIEVEBY="ID" |
The criteria in which to retrieve the message by. The available options are:
|
Remove message from queue |
Yes/No |
No |
No |
REMOVEMESSAGE="YES" |
If set to YES, specifies that the message being retrieved will be removed from the queue upon arrival. This parameter is set to NO by default. |
Private |
Yes/No |
No |
No |
PRIVATE="YES" |
If set to YES, specifies that the newly created queue should be set as private. This parameter is set to NO by default and available only if the Local Machine parameter is enabled. A private queue is a queue registered on the local machine (not in the directory service) that typically cannot be located by other applications. Private queues have the advantage of no directory service overhead (no latency, and no replication), and they can be created and deleted when the directory service is not working. |
Timeout (minutes) |
Number |
No |
5 |
TIMEOUT="7" |
The maximum number of minutes that this activity will wait for the specified message to arrive before throwing a time out error. |
Transactional |
Yes/No |
No |
No |
TRANSACTIONAL="YES" |
If set to YES, specifies that the newly created queue should be set as transactional. This parameter is set to NO by default. Transactional queues can only contain transactional messages, which are messages sent within a transaction. |
Populate dataset with message information |
Text |
No |
(Empty) |
RESULTDATASET="theDataset" |
The dataset name in which to create and populate with information regarding the message being retrieved. More information regarding this parameter can be found below under Dataset. |
Encoding |
Text (options) |
No |
UTF8 |
ENCODING="ASCII" |
The character encoding method to use. This parameter is only available if the Message body type parameter is set to Text. The available options are:
|
Populate variable with message text |
Text |
Yes if message saved to variable. |
(Empty) |
RESULTVARIABLE="theVar" |
Indicates an existing variable in which to populate the contents of the message body. This parameter is only available if the Message body type parameter is set to Text. |
Message File |
Text |
Yes if message saved to file. |
(Empty) |
MESSAGEFILE="c:\temp\Message.txt" |
The path and file name of the text file in which to save the body of the message. If the file does not exist. It will be created at runtime. This parameter is only available if the Message body type parameter is set to File. |
Overwrite if exists |
Yes/No |
No |
No |
OVERWRITE="YES" |
Specifies that if a file with the same name already exists, it will be overwritten with the new message body. This parameter is only available if the Message body type parameter is set to File. |
The Description tab allows you to customize the text description of any step as it appears in the Task Builder's Steps Pane.
More on setting custom step description
The Error Causes tab allows you to select/omit specific errors that should cause a particular step to fail.
More on Error Causes properties
The On Error tab allows you to determine what the task should do if a particular step encounters an error.
More about On Error properties
A dataset is a multiple column, multiple row container object. This activity creates and populates a dataset containing a specific set of fields. The table below describes these fields (assuming the dataset name assigned was theDataset).
Name |
Type |
Return Value |
theDataset.QueuePath |
Text |
Returns the path to the newly created queue. |
theDataset.ID |
Text |
Returns the unique ID for the queue. |
All text fields allow the use of expressions, which can be entered by surrounding the expression in percentage signs (Example: %myVariable% or % Left('Text',2)%). To help construct these expressions, you can open Expression Builder from these fields by clicking the percent sign (%) or pressing F2.