Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The amqp: component supports the AMQP 1.0 protocol using the JMS Client API of the Qpid project. In case you want to use AMQP 0.9 (in particular RabbitMQ) you might also be interested in the Camel RabbitMQ component. Please keep in mind that prior to the Camel 2.17.0 AMQP component supported AMQP 0.9 and above, however since Camel 2.17.0 it supports only AMQP 1.0.

...

Code Block
languagejava
titleAMQP connection details auto-configuration
export AMQP_SERVICE_HOST = "mybroker.com"
export AMQP_SERVICE_PORT = "6666"
export AMQP_SERVICE_USERNAME = "username"
export AMQP_SERVICE_PASSWORD = "password"
 
...
 
@Bean
AMQPConnectionDetails amqpConnection() {
  return AMQPConnectionDetails.discoverAMQP(); 
}

Using topics

To have using topics working with camel-amqp you need to configure the component to use topic:// as topic prefix, as shown below:

Configuring Connection Factory

Like with any other JMS-based component, usually it's important to configure JMS connection factory. For example, you'd like to set your broker url or set proper connection credentials. Additionally, you  

Code Block
     
Code Block
 <bean id="amqpjmsConnectionFactory" class="org.apache.camelqpid.component.amqp.AmqpComponent"jms.JmsConnectionFactory">
        <property name="remoteURI" value="amqp://localhost:5672" />
        <property name="username" value="connectionFactoryadmin"/>
        <property name="password" value="admin"/>
    </bean>

	<bean id="jmsCachingConnectionFactory" class="org.apache.qpid.amqp_1_0.springframework.jms.impl.ConnectionFactoryImpl" factory-method="createFromURL"connection.CachingConnectionFactory">
    	<property name="targetConnectionFactory" ref="jmsConnectionFactory" />
	</bean>

	<bean id="jmsConfig" class="org.apache.camel.component.jms.JmsConfiguration" >
  		<property name="connectionFactory" ref="jmsCachingConnectionFactory" /> 
  		<property name="cacheLevelName" value="CACHE_CONSUMER"  <constructor-arg index="0" type="java.lang.String" value="amqp://localhost:5672" />
 />
 	</bean>	

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

    <camelContext id="simple">
        <route>
           <property name="topicPrefix" value<from uri="topic://" timer:simple?period=5000"/>  <!-- only necessary when connecting to ActiveMQ over AMQP 1.0 -->
            <setBody>
                <simple>Hello World</simple>
          </bean>  </setBody>
            <to uri="amqp:test"/>
        </property>route>
    </bean>

...

camelContext>

Include Page
Endpoint See Also
Endpoint See Also