MSMQ - List Message(s)
Declaration
<AMMSMQ ACTIVITY="list_messages" QUEUE="text" ENABLECACHE="YES/NO" DENYSHAREDMODERECEIVE="YES/NO" RESULTDATASET="text" />
Description: 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.
Practical Usage
Used to retrieve a message that already exists in the queue. This activity throws an error if the specified message does not exist in the queue. In such cases, you can use the Wait for Message activity which allows the task to wait at the current step until a message arrives.
Message Parameters
Property |
Type |
Required |
Default |
Markup |
Description |
---|---|---|---|---|---|
Create and populate dataset with message information |
Text |
Yes |
(Empty) |
RESULTDATASET="text" |
If enabled, specifies that this activity will be performed on the local computer (enabled by default). This is a visual mode parameter used only during design time, therefore, contains no markup. |
Queue Parameters
Property |
Type |
Required |
Default |
Markup |
Description |
---|---|---|---|---|---|
Local computer |
|
|
|
|
If enabled, specifies that this activity will be performed on the local computer (enabled by default). This is a visual mode parameter used only during design time, therefore, contains no markup. |
Another computer |
Text |
No |
(Empty) |
|
If enabled, specifies the host name 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 |
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 |
|
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. |
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 Notes. |
Encoding |
Text (options) |
No |
UTF8 |
|
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 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. |
File |
Text |
Yes if message is saved to file |
(Empty) |
MESSAGEFILE= "c:\temp\Message.txt" |
The path and file name of the text f ile 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. |
Description tab - A custom description can be provided on the Description tab to convey additional information or share special notes about a task step.
Error Causes tab - Specify how this step should behave upon the occurrence of an error. (Refer to Task Builder > Error Causes Tab for details.)
On Error tab - Specify what AWE should do if this step encounters an error as defined on the Error Causes tab. (Refer to Task Builder > On Error Tab for details.)
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
The sample AML code below can be copied and pasted directly into the Steps panel of the Task Builder.
Sample 1: Retrieves the first message from queue "vmwinvx64\Private$\myQueue" on the local machine 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" />
Sample 2: Retrieves a message by lookup ID from queue "vmwinvx64\myQueue" on a remote machine. Queue information is stored in dataset "theMessageInfo". The message body is stored in file ""c:\temp\theMessage.txt".
<AMMSMQ ACTION="retrieve_message" REMOTEMACHINE="machinename" QUEUENAME="vmwinvx64\myQueue" RESULTDATASET="theMessageInfo" RETRIEVEBY="LookupID" MESSAGEID="1234567890" MESSAGEFILE="c:\temp\theMessage.txt" OVERWRITEFILE="YES" REMOVEMESSAGE="YES" />