Since we're on a major migration process of this website, some component documents here are out of sync right now. In the meantime you may want to look at the early version of the new website
https://camel.apache.org/staging/
We would very much like to receive any feedback on the new site, please join the discussion on the Camel user mailing list.
RabbitMQ ComponentAvailable as of Camel 2.12 The rabbitmq: component allows you produce and consume messages from RabbitMQ instances. Using the RabbitMQ AMQP client, this component offers a pure RabbitMQ approach over the generic AMQP component. Maven users will need to add the following dependency to their <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-rabbitmq</artifactId> <version>x.x.x</version> <!-- use the same version as your Camel core version --> </dependency> URI formatrabbitmq://hostname[:port]/exchangeName?[options] Where hostname is the hostname of the running rabbitmq instance or cluster. Port is optional and if not specified then defaults to the RabbitMQ client default (5672). The exchange name determines which exchange produced messages will sent to. In the case of consumers, the exchange name determines which exchange the queue will bind to. Options
See http://www.rabbitmq.com/releases/rabbitmq-java-client/current-javadoc/com/rabbitmq/client/ConnectionFactory.html and the AMQP specification for more information on connection options. Custom connection factory<bean id="customConnectionFactory" class="com.rabbitmq.client.ConnectionFactory"> <property name="host" value="localhost"/> <property name="port" value="5672"/> <property name="username" value="camel"/> <property name="password" value="bugsbunny"/> </bean> <camelContext> <route> <from uri="direct:rabbitMQEx2"/> <to uri="rabbitmq://localhost:5672/ex2?connectionFactory=#customConnectionFactory"/> </route> </camelContext> Headers The following headers are set on exchanges when consuming messages.
The following headers are used by the producer. If these are set on the camel exchange then they will be set on the RabbitMQ message.
Headers are set by the consumer once the message is received. The producer will also set the headers for downstream processors once the exchange has taken place. Any headers set prior to production that the producer sets will be overriden. Message BodyThe component will use the camel exchange in body as the rabbit mq message body. The camel exchange in object must be convertible to a byte array. Otherwise the producer will throw an exception of unsupported body type. SamplesTo receive messages from a queue that is bound to an exchange A with the routing key B, from("rabbitmq://localhost/A?routingKey=B") To receive messages from a queue with a single thread with auto acknowledge disabled. from("rabbitmq://localhost/A?routingKey=B&threadPoolSize=1&autoAck=false") To send messages to an exchange called C ...to("rabbitmq://localhost/B") |