JMS - Apache ActiveMQ Classic Source
Provided by: "Apache Software Foundation"
Support Level for this Kamelet is: "Stable"
Receives each message from a queue or a topic in an Apache ActiveMQ Classic broker, through JMS over OpenWire.
Use it to process work that other applications put on a queue, such as orders or jobs, or to react to events published on a topic. For an Apache ActiveMQ Artemis broker, use jms-apache-artemis-source; for another broker that speaks AMQP 1.0, use jms-amqp-10-source.
Output: the body is text for a JMS text message, bytes for a bytes message, and a Map for a map message. The JMS properties of the message become headers, along with the JMS headers such as JMSMessageID, JMSDestination, JMSTimestamp, JMSPriority and JMSRedelivered.
Good to know: From a queue, each message is removed when it is received, even when the rest of the flow then fails, unless transacted is true or acknowledgementModeName is CLIENT_ACKNOWLEDGE: then a message whose flow failed is delivered again, up to 6 more times, and then moved to the dead letter queue ActiveMQ.DLQ. Several copies of this source share the messages of a queue, and concurrentConsumers processes several messages at the same time. From a topic (destinationType set to topic), it receives only the messages sent while it is connected, unless subscriptionDurable is true: then the broker keeps the messages sent while it is stopped, under clientId and subscriptionName. ActiveMQ Classic has no shared subscriptions (JMS 2.0), so each copy of the source on a topic receives every message. With selector, it receives only the messages whose properties and headers match the selector. It connects with no TLS unless brokerURL starts with ssl://, and logs in with username and password when they are set. When the broker cannot be reached, or refuses the login, it starts anyway and tries again every 5 seconds. An answer is sent only when the incoming message has a JMSReplyTo, the queue on which its sender waits for one: the message at the end of the flow then goes back to that queue, as the reply. Headers set during the flow, such as JMSReplyTo or CamelJmsDestinationName, cannot send the answer to another queue, nor make one for a message without JMSReplyTo.
Configuration Options
The following table summarizes the configuration options available for the jms-apache-activemq-source Kamelet:
| Property | Name | Description | Type | Default | Example |
|---|---|---|---|---|---|
Broker URL | Required The address of the ActiveMQ Classic broker, as | string | tcp://localhost:61616 | ||
Queue or Topic Name | Required The name of the queue or topic to receive the messages from. | string | orders | ||
Acknowledgement Mode | When the source acknowledges each message to the broker, which then removes it from the queue. Enum values: * AUTO_ACKNOWLEDGE * CLIENT_ACKNOWLEDGE * DUPS_OK_ACKNOWLEDGE | string | |||
Client ID | The JMS client ID of the connection, which names this application to the broker. A durable subscription needs one: the broker keeps the subscription under the client ID and | string | orders-service | ||
Concurrent Consumers | How many messages the source processes at the same time, each in a thread of its own. From a queue, more than one makes the source faster when each message takes a while, but the messages are then no longer processed in the order of the queue. On a topic, each consumer is a subscription of its own and receives every message, so each message is processed that many times; a durable subscription takes only one consumer. When it is not set, one message at a time. | integer | 5 | ||
Queue or Topic | Whether Enum values: * queue * topic | string | queue | ||
Broker Password | The password to log in to the broker with, for the user | string | |||
Message Selector | A JMS message selector: the source receives only the messages that match it. It is a condition, in a syntax like the WHERE clause of SQL, on the JMS properties and headers of the message, not on its body, such as | string | priority > 5 | ||
Durable Subscription | Whether the subscription to a topic is durable. When it is true, the broker keeps the messages sent to the topic while this source is stopped or disconnected, and delivers them when it connects again; the broker keeps the subscription, and collects messages for it, until it is removed in the broker. Set | boolean | false | ||
Subscription Name | The name of the durable subscription to a topic, under which the broker keeps the subscription, together with | string | orders-audit | ||
Transacted | Whether each message is received in a JMS transaction, which is committed once the rest of the flow has processed the message. When the flow fails, the transaction is rolled back and the message is delivered again, with the header | boolean | |||
Broker Username | The user name to log in to the broker with. Leave it empty for a broker that accepts clients without a login. | string |
Dependencies
At runtime, the jms-apache-activemq-source Kamelet relies upon the presence of the following dependencies:
-
camel:jms
-
camel:kamelet
-
mvn:org.apache.activemq:activemq-client:6.3.2
Camel JBang usage
Prerequisites
-
You’ve installed JBang.
-
You have executed the following command:
jbang app install camel@apache/camel Supposing you have a file named route.yaml with this content:
- route:
from:
uri: "kamelet:jms-apache-activemq-source"
parameters:
.
.
.
steps:
- to:
uri: "kamelet:log-sink" You can now run it directly through the following command
camel run route.yaml