IBM MQ Listener
The IBM MQ Listener activity listens on a queue and when a message arrives that satisfies the configured filters it retrieves and it starts a process including the contents of the message.
The listener can poll a queue based on interval and timeout values, or it can wait indefinitely on a queue. Regardless of the mode, when messages arrive on the queue and the listener is running, they are each processed immediately with no intervening interval time.
get methods. So even though, the Listener activity is instructed to stop, it cannot terminate the currently executing thread, which is waiting on the
get call. In a polling Listener activity, this situation is resolved when the timeout interval expires and the thread exits. However, a non-polling Listener activity never exits the
get call. There are two scenarios to show this situation.
- A message arrives after a Listener activity is stopped. In this scenario, the message is rolled back if there is a unit of work in effect. If there is no unit of work, the message is returned to the queue through a
putcall. Note that if the listener does not have the authority to put the message back on the queue, it attempts to put it on the dead letter queue. If there is no dead letter queue or there is an error putting the message on it, the message is lost and an error message is issued. - There are two listeners in the same queue after you start a new listener. Normally this is not an issue, because when a new message arrives, the first listener exits. However, if the queue is configured to be opened only by one listener, the newly started listener gets errors while connecting. It continues to attempt to connect and issue warning messages periodically. Until a message arrives, it terminates the first listener, after that, the newly started listener connects and processes the message.
There is another general scenario, which affects all process starters. If the Listener activity receives a number of messages and creates processes for them, but those processes are either running or waiting to run without adding checkpoints and the engine is shut down, those messages are lost. If it is imperative that messages are never lost, you can select the Require Client Confirmation checkbox in the General tab to ensure their integrity.
General
The General tab of the Listener activity contains the following fields:
| Field | Module Property? | Description |
|---|---|---|
| Name | N | The name to be displayed as the label for the activity in the process. |
| Connection | Y | The connection resource which connects this activity with the queue manager that has access to the desired queue. |
| Instances | Y | Enter the number of instances of the queue listener you want this activity to run. This translates to the number of threads and connections to the queue manager created by this activity.
The default is 1 and the maximum is 64. If the Require Client Confirmation checkbox is selected, each thread this activity runs waits for the confirmation before getting another message from the queue. Therefore, to process messages in an absolute serial fashion, start only one instance of the listener. In this case, the number of messages processed becomes a function of how much latency exists in the activity before the confirmation. |
| Destination | Y | The name of the queue from which the message is retrieved. |
| Dynamic Destination | N | A flag that enables the creation of a dynamic queue. When selected, the Dynamic Destination Model field is enabled. |
| Dynamic Destination Model | Y | Provide the name of the model queue after which this dynamic queue is patterned. This field is only available when the
Dynamic Destination checkbox is selected.
Note: It is good practice that static queue names (queue names that do not contain a pattern) be used for listener activities. If a pattern is used for a Listener activity queue name, the name generated by the queue manager is not available until the listener creates a process that makes it impossible for a sender to know the name.
|
| Message Content Type | N | Select the type of message contents:
|
| Message Body Fields | Y | If the message has been written using the MQMessage read/write API calls, use this field to map a schema conforming to the message body. |
| Fail If Quiescing | N | Select the Fail If Quiescing checkbox to prevent this listener from holding up a queue manager quiesce operation. If the queue manager does terminate, the activity attempts to reconnect indefinitely. |
| Access Mode | N | Select the access mode for the queue:
|
| GMO Convert | N | Causes the get message option
MQGMO_CONVERT to be used for this
get operation. It causes the queue manager to convert string and numeric fields using the
characterSet and
encoding elements before the data is copied to the message buffer.
|
| Require Client Confirmation | N | Select the
Require Client Confirmation checkbox to request the explicit confirmation of a received message.
The confirm activity can be used to confirm the message’s arrival and remove it from the queue. The plug-in uses the queue manager's syncpoint capability to ensure that the message is only removed from the queue if it is confirmed. Note: The activity waits for the confirmation before obtaining another message which imposes a limit on throughput. If serial processing of the messages is not essential, raise the value of the
Instances field until the desired throughput is achieved.
If the activity fails to confirm the message, it loops and repeatedly processes the same message. To avoid this behavior, it is good practice to copy the message to an error queue and then confirm the original. |
| Logger Name | Y | Enter the name of any pre-configured logger available for the run time. Loggers are configured in an XML document referenced by the Dlogback.configurationFile runtime parameter. |
Description
A short description of the Listener activity.
Multi-Message
The Multi-Message tab of the Listener activity contains the following fields:
| Field | Module Property? | Description |
|---|---|---|
| Multi-Message Support | N | Two options are supported:
If BatchGroup is selected, an activity is started by a listener to operate in the batch mode that contains multiple InteractionOutput nodes, each representing one message in the batch. You can determine the number of discrete messages to be included in the batch with the Batch Size field enabled. When None is selected, the Listener activity processes a single message at one time from the queue. The main use for BatchGroup mode is to process an entire logical message in a single job. Note: If the
Require Client Confirmation checkbox is selected for a batch, the entire batch is confirmed when the Confirm activity runs. If an error is detected while processing a message, the entire batch must be reprocessed.
|
| Batch Size | Y | If BatchGroup is selected, this field becomes enabled. Enter valid inputs range from 1 to 100 to control the size of the batches retrieved by this listener. |
| Batch Delay Interval | Y |
When Required Client Confirmation is enabled and the batch is incomplete, the listener waits for a specified time interval. This time interval is called Batch Delay Interval. After the time interval is over, the listener confirms the batch messages even if the batch is incomplete. If the batch delay interval is set to 0, the listener waits for an unlimited duration to complete a batch. Unit: seconds Valid range: 0 to 120 Default: 0 |
| Complete Message | N | Enable this field to cause the listener to only process the first member of a logical message when all the members of the logical message have been written to the queue. This must be deselected when processing incomplete logical messages and when processing huge logical messages one message at a time. |
| Get Ordered | N | Select this field to cause logical messages to be processed in the order in which they are created. To process incomplete logical messages, do not select this field. This option requires that the queue be indexed, otherwise, it is disabled dynamically at run time. |
| Explicit Commit | N | Every attempt is made within the plug-in to avoid unnecessary commits because of the overhead involved. However, you might select this checkbox to force the creation of a unit of work and subsequent commit. The commit happens after any application properties and message body fields have been processed, so selecting this checkbox protects you from removing a message from the queue only to fail while processing the contents. Message contents can cause failures if, for example, the encoding or character set is inappropriate for the data, or the schema used to process the message is in error. |
| Syncpoint Used | N | This field is not a configuration parameter but is a status indication of whether the activity is configured to require a syncpoint or not. Because of the cost of syncpoint operations, every effort has been made to avoid them. If the activity requires confirmation or uses multiple messages, a sync is required. |
| Poison Msg Detection | N | Select this checkbox to turn on poison message detection. If the Listener activity processes a message where the backout count is greater than the poison message threshold, the message is not processed but is moved to the designated poison message queue. This prevents the Listener activity from looping on a message that cannot be confirmed. Note that this checkbox is only available after you select the Require Client Confirmation checkbox and click None from the Multi -Message Support area in the Listener activity. |
| Poison Msg Threshold | Y | Enter the backout count at which a message is considered poison. If the backout exceeds this value, it is moved to the poison message queue. |
| Poison Msg Queue | Y | Enter the queue to which poison messages are moved. |
Advanced
The Advanced tab of the Listener activity contains the following fields:
| Field | Module Property? | Description |
|---|---|---|
| Sequence Key | N | This field can contain an XPath expression that specifies which processes are required to run, and in which order. Process instances with sequencing keys that evaluate the same value are executed sequentially in the order the process instance is created.
See the TIBCO ActiveMatrix BusinessWorks documentation for more information about controlling the execution order of process instances and about XPath expressions. |
| Custom Job Id | N | This field can contain an XPath expression that specifies a custom ID for the process instance. This ID is displayed in the View Service dialog of TIBCO Enterprise Administrator, and it is also available in the $_processContext process variable. |
| Enable Polling | N | When selected, the activity instantiates a connection to the queue manager and opens the queue. It then periodically issues timed gets on the queue where the timeout value is equal to the polling timeout and the period between gets is equal to the polling interval.
However, if there are multiple messages in the queue they are processed without an intervening polling interval, thus diminishing application latency. When cleared, the activity waits forever in the queue, processing messages as they arrive. If the queue manager connection fails, the activity attempts to reconnect based on the reconnection interval. If the listener is not polling, it is doing an unbounded get on the queue, and the listener does so even after the application is set to stop using the administrator or shell command. To release the connection and close the destination, you must stop the appNode on which this application is running. This also means that if you redeploy the application without recycling the appNode, the connections from the previous deployment persist until the node is recycled. This is because there is no safe way to interrupt an IBM MQ native Java API get method. Note: A poor choice of polling interval and polling timeout values might impose a high overhead on the engine as well as the queue manager to which the activity is connected. Use values here which take into account the latency in the network between this activity and the queue manager, as well as the processing demands you are willing to place on that queue manager.
|
| Polling Interval | Y | If the
Enable Polling checkbox is selected, this is the interval at which a new polling cycle is initiated.
Specify the time in milliseconds. Valid range: 100 to 1000000 Default: 1000 |
| Polling Timeout | Y | If the
Enable Polling checkbox is selected, this is the timeout value for each individual listen. The value specified here must be significantly smaller than the polling interval. This minimizes the number of concurrent connections to the queue and reduces the processing resources needed.
Specify the time in milliseconds. Valid range: 10 to 1000000 Default: 1000 |
| Reconnection Interval | Y | The length of time, in milliseconds, that the listener waits between attempts to reconnect to the queue.
This setting is used only when the Enable Polling checkbox is cleared. If the Enable Polling checkbox is cleared, the Listener activity listens indefinitely on the queue. However, if an error occurs and the queue manager is subsequently unavailable (shut down for example), this value is the number of milliseconds between reconnection attempts. Valid range: 2000 to 1000000 Default: 10000 |
| Filter Encoding | N | This field specifies the encoding of the values provided in the
Correlation Id,
Message Id, and
Group Id fields. The
Filter Encoding field provides three types of values:
text,
base64, and
hexbin.
When this field is set to either base64 or hexbin, the values of the three Id fields are transformed appropriately to form a binary filter as follows. For example, a valid base64 filter is bzkMF27syhmb37nm8kPQojEupbpNVJHm and a valid hexbin filter is 6f390c176eecca199bdfb9e6f243d0a2312ea5ba4d5491e6. Note that you do not use the prefix "0x" with the hexbin filter. |
| Correlation Id | Y | The Listener activity instructs the queue manager to filter the request based on this correlation ID. Only messages with the same ID are accepted. |
| Message Id | Y | The Listener activity instructs the queue manager to filter the request based on the specified message ID.
Note: In contrast to correlation IDs, message IDs are always provided. If the listener does not explicitly state a message ID, it accepts any message. If an ID is provided, the listen is filtered for that message ID.
|
| Group Id | Y | The Listener activity instructs the queue manager to filter the request based on the specified group ID. Only messages with the same group ID are accepted. |
| Application Properties | N | Select the Application Properties resource to be used to map the output of this get. Application properties are similar to regular message header fields except that the name and type of the fields can be determined by a predefined schema. If the received message contains properties, they are mapped according to this schema.
To use application properties, create a generic XML schema composed of a node with simple elements inside it and map that schema to this field. See the IBM MQ documentation for property types supported by the level of client you have installed. Note: A failure to observe cardinality results in errors, processing the input or output schema.
|
| Property Control | N | Select one of the following settings:
After selecting one of these options, you can use the Listener activity to inter-operate with various versions of IBM MQ applications. Which option to use varies depending on the sending application. See the section entitled "MQGMO message property option setting" in the IBM MQ documentation for detailed information. |
Conversations
You can use the Conversations tab of the Listener activity to initiate or join a conversation.
Conversations receive messages after the creation of a process instance, which is initiated or joined by an activity. This activity can be used to initiate a conversation. Click the
Add New Conversation
icon to initiate a conversation. For more details regarding conversations, see
TIBCO ActiveMatrix BusinessWorks Application Development.
Output
The following table lists the output items for the Listener activity:
| Output Item | Module Property? | Description |
|---|---|---|
| Batch | N | If BatchGroup in the Multi-Message tab is selected, this node is present and contains an InteractionOutput node for each message retrieved as part of this batch. |
| InteractionOutput | N | The root node for all the output provided by the activity. |
| mqproperties | N | The node containing all the message header fields (plus the destination override) which are relevant to output.
|
| dynamicProperties |
|
|
| bytes | N | The output body of the message. Typically, this byte array is to be mapped as input to a Data Conversion Plug-in parse activity.
This field is only displayed when Binary is selected in the Message Content Type area. |
| text | N | If the activity is configured to use text messages then this node is present instead of the
bytes field. The contents of the message are decoded into a string using the Java default encoding and presented here.
This field is only displayed when Text is selected in the Message Content Type area. |
| responsetimemillisec | N | The time, in milliseconds, that the listener takes to receive this message. It is measured from when the listener starts listening to when it finishes creating the event context passed to the remaining activities in this process. |
| appProperties | N | This field maps the application properties present in the received message to the schema attached to the activity and only displays if application properties are mapped on the Advanced tab. Properties that are missing or not present in the schema are not shown here. |
| messageFields | N | Contains the message body formatted using
Schema in the
Message Content Type field of the
General tab. Each field in the schema is mapped here.
This field is displayed for schema-based messages only. |
Fault
The Fault tab lists exceptions that occur in the Listener activity:
| Error Schema Element | Data Type | Description |
|---|---|---|
| msg | String | The ActiveMatrix BusinessWorks Plug-in for IBM MQ error message. |
| msgCode | String | The ActiveMatrix BusinessWorks Plug-in for IBM MQ error code. |
| mqCompCode | String | If the message originates as an IBM MQ API exception, then that exception's completion code is here. |
| mqReasonCode | String | If the message originates as an IBM MQ API exception, then that exception's reason code is here. |
| mqErrorCode | String | If the message originates as an IBM MQ API exception, then that exception's reason code is here. |