MSMQ - Wait for message

Declaration

<AMMSMQ ACTIVITY="wait_message" REMOTEMACHINE="text" QUEUE="text" ENABLECACHE="YES/NO" DENYSHAREDMODERECEIVE="YES/NO" ACCESSMODE="" LABEL="text" RESULTVARIABLE="text" RESULTDATASET="text" TIMEOUT="number" REMOVEMESSAGE="YES/NO" ENCODING="text (options)" OVERWRITEFILE="YES" />

Related Topics   

Description

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.

IMPORTANT: MSMQ must be installed on the (local or remote) computer in order for these activities to function properly. MSMQ is bundled with most Microsoft Windows operating systems, however, it is not installed by default. For more details regarding the installation of MSMQ, see MSMQ Installation & Overview.

Practical usage

The MSMQ - Retrieve message activity throws an error if the specified message does not exist in the queue. Use this activity before the Retrieve message activity to allow the task to wait at the current step until a message arrives.

Parameters

Message

Property Type Required Default Markup Description
Label Text Yes (Empty) LABEL="theCoolMessage" The label of the message to send. This label can be used in the MSMQ - Wait for message activity to allow for a specific message to wait for.  
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:
  • Text (default) - Message will be in text format and saved to a variable.
  • File - Message will be saved directly to a text file.
Populate automate variable with message text Text Yes if message is  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.
Encoding Text (options) No UTF8
  • ENCODING="UTF8"
  • ENCODING="UTF7"
  • 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:
  • UTF8 (Default)
  • UTF7
  • ASCII
Create and populate dataset with message information Text No (Empty) RESULTDATASET="theMessage" 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 MSMQ - Wait for message.
File Text Yes if message is 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 Body type parameter is set to File.
Overwrite 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 Body type parameter is set to File.

Queue

Property Type Required Default Markup Description
Local computer --- --- --- --- If enabled, specifies that this activity will be performed on the local computer (enabled by default).
NOTE: This parameter does not contain markup and is only displayed in visual mode for task construction and configuration purposes.
Another computer Text No (Empty)
  • REMOTEMACHINE="CompName"
  • REMOTEMACHINE="xxx.xxx.xxx.xxx"
If enabled, specifies the hostname or IP address of the remote computer that this activity will be performed on. When this parameter is enabled, the Local computer parameter is ignored.
Queue path Text Yes (Empty) QUEUENAME="HostName\QueueName" The name of the message queue to gather messages from. The queue name consists of the computer name, an optional PRIVATE$ keyword that indicates whether it is a private queue and the name of the queue.
  • Sample public queue name: ComputerName\QueueName
  • Sample private queue name: ComputerName\PRIVATE$\QueueName

Description

Error Causes

On Error

Additional notes

Datasets

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.Label

Text

Returns the label text included with the message.

theDataset.ID

Text

Returns the message ID, which is a 20-byte Message Queuing-generated identifier.

theDataset.LookupID

Text

Returns the Lookup ID, which is a 64-bit ID that is assigned to the message when it is placed in the queue.

theDataset.SentTime

Date/Time

Returns the date/time when the message was sent.

theDataset.ArriveTime

Date/Time

Returns the date/time when the message was retrieved.

theDataset.Priority

Text

Returns the message priority.

theDataset.SourceMachine

Text

Returns the machine name where the message originated from.

Example

NOTE:
  • Copy and paste the sample AML code below directly into the Task Builder Steps Panel.
  • To successfully run the sample code, update parameters containing user credentials, files, file paths, or other information specific to the task to match your environment.

Description

This sample task creates a queue, sends message to that queue, waits for the message, retrieves the message, and then purges the queue.

Copy
<!-- Create variable -->
<AMVARIABLE NAME="theVar" VALUE="" />
<!-- Create private queue -->
<AMMSMQ PRIVATE="YES" NAME="myPrivateQueue" RESULTDATASET="privateQueueData" />
<!-- Send message to queue -->
<AMMSMQ ACTIVITY="send_message" QUEUENAME="vmwinvx64\Private$\myPrivateQueue" MESSAGELABEL="Support" MESSAGEFILE="C:\Users\techsupport\Desktop\cd.txt" />
<!-- Wait for message -->
<AMMSMQ ACTIVITY="wait_message" QUEUE="vmwinvx64\Private$\myPrivateQueue" LABEL="Support" RESULTVARIABLE="theVar" />
<!-- Retrieve message -->
<AMMSMQ ACTIVITY="retrieve_message" QUEUENAME="vmwinvx64\Private$\myPrivateQueue" RESULTDATASET="data" MESSAGEFILE="C:\Users\techsupport\Desktop\rt.txt" OVERWRITEFILE="YES" REMOVEMESSAGE="YES" />
<!-- Purge queue -->
<AMMSMQ ACTIVITY="delete_queue" QUEUENAME="vmwinvx64\Private$\myPrivateQueue" />