MSMQ - Clear Queue

Declaration

<AMMSMQ ACTIVITY="clear" QUEUE="text" REMOTEMACHINE="text" />

Description: 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.

IMPORTANT: MSMQ activities are performed using the Microsoft Message Queuing engine, therefore, MSMQ must be installed on the computer that will run such operations. MSMQ software comes bundled with all Microsoft Windows operating systems from Windows 2000 up to, and including Windows 8, however, it is not installed by default. For more details regarding the installation of MSMQ, see MSMQ Installation & Overview.

Practical Usage

Removes messages that exist in the specified queue.

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)

  1. REMOTEMACHINE="CompName"

  2. REMOTEMACHINE="xxx.xxx.xxx.xxx

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 purge. The message 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.

Public queue example: ComputerName\QueueName

Private queue example: ComputerName\PRIVATE$\QueueName

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

Example

The sample AML code below can be copied and pasted directly into the Steps panel of the Task Builder.

Description: A simple task that creates a queue, sends message to that queue, waits for the message, retrieves the message and purges the queue.

<!-- Create variable -->
<AMVARIABLE NAME="theVar" />
<!-- 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_for_message" 
QUEUENAME="vmwinvx64\Private$\myPrivateQueue" 
RESULTDATASET="data" 
MESSAGELABEL="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" />