JMS on demand poller

1. Overview

The JMS OnDemand Poller takes one message on demand from a queue, at the moment a message passes through it. To start a flow whenever a message arrives, use the JMS listener instead.

The poller reads queues only. The Studio also offers the TOPIC topology, but the poller then uses the topic name as the name of a queue and does not read from the topic. To receive messages from a topic, use a JMS listener with topic topology.

The message is put in the MessagePart named in MessagePart Out. If no message arrives within Receive Time-out, you choose what happens: the flow stops quietly, or a time-out message is sent further into the service chain.

2. Which messages it reads

JMS message type Result

Text message

The text is put in MessagePart Out as a text part.

Binary message (BytesMessage)

The bytes are put in MessagePart Out as a binary part, as the JMS listener does.

Any other type, for example a map message, an object message or a message without a body

The service stops with an error and the flow goes to the error flow. The error reads JMS OnDemand Poller cannot read a <class> from <destination>; only TextMessage and BytesMessage are supported, where <class> is the Java class name that the broker gives the message, for example org.apache.activemq.command.ActiveMQMapMessage.

Since 5.3.1 a binary message is read, and a message of another type stops the service with an error. Before, such messages were removed from the queue and dropped without an error.

The JMS headers of the message and its own message properties are stored as properties of the MessagePart. A JMS header whose value cannot be stored there is skipped and mentioned in the log. A message property of that kind is skipped without a log entry.

The poller does not use a JMS transaction. As soon as it has received a message, that message is removed from the queue, also when the message is of an unsupported type and the flow fails, and also when a later step of the flow fails. A JMS Acknowledgement or JMS Rollback after the poller has no effect.

If a message must not be lost when the flow fails, start the flow with a JMS listener in flow_transacted or session_transacted mode instead. There is no transactional option for polling in the middle of a flow: the poller always removes the message. If you must poll in the middle of a flow, make sure the message content is kept when a later step fails, for example by sending it to an error queue with a JMS Sender in the error flow. That does not help when the poller step itself fails.

3. Receive time-out

The poller waits for a message for at most Receive Time-out milliseconds, and the flow waits with it. The default is 60000 (one minute). A value of -1 does not wait at all: if there is no message at that moment, the poller times out immediately. A value of 0 waits until a message arrives.

When the time-out expires without a message, the agent log shows a warning:

No Message received within timeout from destination: <destination>

What happens next depends on Time-out Message:

  • Time-out Message is empty: the poller sends nothing further and the flow stops at the poller, without an error.

  • Time-out Message has a value: that text is put in MessagePart Out and the flow continues. A later step cannot tell this text from a real message other than by its content, so choose text that you can test for, for example in a filter.

A message that takes longer to arrive than Receive Time-out, for example a large message over a slow connection, is not received completely. Set Receive Time-out higher than the longest transfer you expect, for example 300000. The flow waits that long on an empty queue too.

4. Properties

All attributes with a * are mandatory.

All attributes with a '** ' require exactly one of these properties having been set.

The JMS OnDemand Poller properties
Attribute Description

Name*

By default, we fill this out with the technical tag, followed by a serial number. Changing the name is optional.

Enabled

Set this value to true, if you want this service enabled at startup.

JMS Topology

Here you can choose between QUEUE and TOPIC. The default is QUEUE. Use QUEUE: the poller does not read from topics. The screen adjusts accordingly.

Request Queue Name**

Name of the queue to receive from. Shown with QUEUE topology. Cannot be combined with Request Queue Header.

Request Topic Name**

Shown with TOPIC topology. Do not use: the name is used as the name of a queue, not of a topic.

Request Queue Header**

Name of the header of the incoming message that contains the name of the queue to receive from. Shown with QUEUE topology. If the header is missing or empty, the service fails with an error.

Request Topic Header**

Shown with TOPIC topology. Do not use: the name in the header is used as the name of a queue, not of a topic.

MessagePart Out

The name of the MessagePart that is used as output of the service. The message from the destination, or the time-out message, is put in this MessagePart before the message is sent to the next service or the producer. The default value is msgprt0.

Connection Factory

Name of the connection factory to use; it determines which JMS environment is used. The default jmsConnectionFactory uses the factory named in property connect.connectionfactory.name in connectplaza-agent.properties, by default activeMQFactory, the built-in ActiveMQ broker of the agent. To use another broker, see Adding a new broker for JMS.

Receive Time-out

The time in milliseconds the service waits for a message. The default is 60000. See Receive time-out.

Time-out Message

The text that is sent if no message has been found after Receive Time-out has expired. By default no message is sent and the flow stops.

The older attributes Destination and Destination Reference are deprecated. Existing interfaces keep working. Use the request queue attributes in new interfaces.