Triggers Overview

Applies To: Windows Server 2008

Triggers overview

Message Queuing Triggers is a service that allows you to associate the arrival of each incoming message at a queue with a response that depends on the contents of the message and may invoke either a COM component or a stand-alone executable program. You can use Message Queuing Triggers to define business rules that can be invoked in response to such messages without any additional programming. Ordinarily, to provide such message-handling functionality, application developers would have to create a receiving application that invokes specific behavior on a per-message basis. By using Message Queuing Triggers, specific behavior can be invoked at the queue level. Application developers no longer need to write any infrastructure code to provide such message-handling functionality. Triggers can be associated with queues located on the local computer and a remote computer.

Triggers are not installed by default during Message Queuing installation. For information about installing triggers, see Installing Message Queuing Triggers.

Triggers security

By default, the Message Queuing Triggers service runs under the Network Service account. Services that are running under this account interact with the network using the credentials of the computer account, and this account has the same level of access to resources and objects as members of the Users group accounts. You can specify a less secure account for the Triggers service; for example, the Local System account, allowing access to the entire domain. Note that the Triggers service running under the Network Service account does not interact with the desktop. If this functionality is required, you can configure the Triggers service to run under the Local System account and enable interaction with the desktop in Computer Management.

The account used must be able to access the queues with which triggers are associated. Specifically, the account must be granted the Log On As A Service permission and the Peek Message permission for all applicable queues. If the message processing type of a trigger is "retrieval" or "transactional retrieval," the user must be granted the Receive Message permission for that queue. If you change the security settings for a queue to enable a trigger to monitor it, you must stop and start Triggers to update the service's configuration before the trigger will start to work. Note that executable files invoked by triggers are invoked with the same security privileges as those assigned to the Triggers service.

The Triggers service must run under an account with administrator permissions.

Serialized and nonserialized triggers

Message Queuing triggers can be serialized or nonserialized. The type of triggers you define for a specific queue will affect how the Message Queuing Triggers service processes incoming messages. If you create multiple triggers for a particular queue and at least one of them is serialized, all the triggers will behave as serialized triggers, even if they are not defined as serialized. Triggers with the transactional-retrieval processing type can only be serialized.

A serialized trigger processes messages in the order in which they arrive, testing each message for the conditions of all the rules associated with it and performing all the applicable actions before moving on to the next message. When serialized triggers are defined, the throughput of the Message Queuing Triggers service is lower than for nonserialized triggers because the messages are processed one at a time and the service must wait until all the operations performed on each message are completed.

Nonserialized triggers process messages faster, but the messages are not necessarily processed in the order in which they arrived. Nonserialized triggers provide a faster throughput because the Message Queuing Triggers service does not wait for all the operations performed on one message to be completed before starting to process the next message. It is recommended that you use only one trigger with the serialized option because the order of trigger firing is random with respect to their GUIDs.

Trigger elements

Each trigger is associated with a specific monitored queue on the local computer and is invoked by the Message Queuing Triggers service for every Message Queuing message arriving at that queue. A trigger is configured to obey one or more rules. A rule is defined by one or more conditions and an action in the form of an executable file or COM component that is executed when all the conditions associated with the rule are evaluated as true.

A trigger is an automatic mechanism for implementing a specific action in response to a message event. In the context of Message Queuing Triggers, an event is defined as a set of one or more conditions that may be satisfied by a message arriving in a queue. The collection of all triggers on a particular computer is called the trigger set.

A condition is a criterion that is applied to a message when it arrives at a monitored queue. A condition can test only for a property of the message. Every condition or set of multiple conditions is associated with an action.

An action results when a condition or a set of multiple conditions is true. An action can be expressed as an executable and a parameter list, or as a COM component, a method, and a parameter list. You can also invoke other types of files by making them parameters of an .exe file. For example, you can invoke an .msc file by specifying mmc.exe as the executable file and the full path of the .msc file as a parameter.

A rule is a condition-action pair. A rule specifies the action that will be taken when a specific condition or set of conditions is true. The collection of all rules (for all triggers) on a particular computer is called the rule set.