ActiveMQ has been edited by Claus Ibsen (Jul 02, 2009).

(View changes)


ActiveMQ Component

The ActiveMQ component allows messages to be sent to a JMS Queue or Topic; or messages to be consumed from a JMS Queue or Topic using Apache ActiveMQ.

This component is based on the JMS Component and uses Spring's JMS support for declarative transactions, using Spring's JmsTemplate for sending and a MessageListenerContainer for consuming. All the options from the JMS component also applies for this component.

To use this component make sure you have the activemq.jar or activemq-core.jar on your classpath along with any Camel dependencies such as camel-core.jar, camel-spring.jar and camel-jms.jar.

URI format


Where destinationName is an ActiveMQ queue or topic name. By default, the destinationName is interpreted as a queue name. For example, to connect to the queue, FOO.BAR, use:


You can include the optional queue: prefix, if you prefer:


To connect to a topic, you must include the topic: prefix. For example, to connect to the topic, Stocks.Prices, use:



See Options on the JMS component as all these options also apply for this component.

Configuring the Connection Factory

The following test case shows how to add an ActiveMQComponent to the CamelContext using the activeMQComponent() method while specifying the brokerURL used to connect to ActiveMQ

camelContext.addComponent("activemq", activeMQComponent("vm://localhost?broker.persistent=false"));

Configuring the Connection Factory using Spring XML

You can configure the ActiveMQ broker URL on the ActiveMQComponent as follows

<beans xmlns=""

  <camelContext xmlns="">

  <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
    <property name="brokerURL" value="tcp://somehost:61616"/>


Using connection pooling

When sending to an AcitveMQ broker using Camel its recommended to use a JMS connection pooling such as Jencks. See more here Jencks Connection Pooling

You can grab Jencks AMQ pool with maven:


And then setup the activemq Camel component as follows:

<!-- use jencks connection pooling so its more effecient to send JMS messages -->
    <amqpool:pool id="jmsConnectionFactory" xmlns:amqpool=""

    <bean id="jmsConfig" class="org.apache.camel.component.jms.JmsConfiguration">
        <property name="connectionFactory" ref="jmsConnectionFactory"/>
        <property name="transacted" value="false"/>
        <property name="concurrentConsumers" value="10"/>

    <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
        <property name="configuration" ref="jmsConfig"/>

Invoking MessageListener POJOs in a Camel route

The ActiveMQ component also provides a helper Type Converter from a JMS MessageListener to a Processor. This means that the Bean component is capable of invoking any JMS MessageListener bean directly inside any route.

So for example you can create a MessageListener in JMS like this....

public class MyListener implements MessageListener {
   public void onMessage(Message jmsMessage) {
       // ...

Then use it in your Camel route as follows


That is, you can reuse any of the Camel Components and easily integrate them into your JMS MessageListener POJO!

Getting Component JAR

You need these dependencies

  • camel-jms
  • activemq-camel


You must have the camel-jms as dependency as ActiveMQ is an extension to the JMS component.


The ActiveMQ Camel component is released with the ActiveMQ project itself.
For Maven 2 users you simply just need to add the following dependency to your project.

ActiveMQ 5.2 or later


ActiveMQ 5.1.0

For 5.1.0 its in the activemq-core library


Alternatively you can download the component jar directly from the Maven repository:

ActiveMQ 4.x

For this version you must use the JMS component instead. Please be careful to use a pooling connection factory as described in the JmsTemplate Gotchas

See Also

Powered by Atlassian Confluence (Version: 2.2.9 Build:#527 Sep 07, 2006) - Bug/feature request

Unsubscribe or edit your notifications preferences