Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

...

RabbitMQ

...

Component

...

Available

...

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

...

pom.xml

...

for

...

this

...

component:

Code Block
xml
xml


{code:xml}
<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>
{code}

h3. URI format

{code

URI format

Code Block
}
rabbitmq://hostname[:port]/exchangeName?[options]
{code}

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 

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

Wiki Markup


h3. Options
{div:class=confluenceTableSmall}
|| Property || Default || Description ||
| {{autoAck}} | {{true}} | If messages should be auto acknowledged |
| {{autoDelete}} | {{true}} | If it is true, the exchange will be deleted when it is no longer in use |
| {{durable}} | {{true}} | If we are declaring a durable exchange (the exchange will survive a server restart) | 
| {{queue}} | {{random uuid}} | The queue to receive messages from |
| {{routingKey}} | {{null}} | The routing key to use when binding a consumer queue to the exchange. For producer routing keys, you set the header (see header section) |
| {{threadPoolSize}} | {{10}} | The consumer uses a Thread Pool Executor with a fixed number of threads. This setting allows you to set that number of threads. |
| {{username}} | {{null}} | username in case of authenticated access |
| {{password}} | {{null}} | password for authenticated access |
| {{vhost}} | {{/}} | the vhost for the channel |
| {{exchangeType}} | {{direct}} | *Camel 2.12.2:* The exchange type such as direct or topic. |
| {{bridgeEndpoint}} | {{false}} | *Camel 2.12.3:* If the bridgeEndpoint is true, the producer will ignore the message of rabbitmq.EXCHANGE_NAME |
{div}

h3. Headers

The following headers are set on exchanges when consuming messages.

Headers

The following headers are set on exchanges when consuming messages.

Wiki Markup
{div:class=confluenceTableSmall}
|| Property || Value ||
| {{rabbitmq.ROUTING_KEY}} | The routing key that was used to receive the message, or the routing key that will be used when producing a message |
| {{rabbitmq.EXCHANGE_NAME}} | The exchange the message was received from |
| {{rabbitmq.DELIVERY_TAG}} | The rabbitmq delivery tag of the received message |
{div}

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.

Wiki Markup

{div:class=confluenceTableSmall}
|| Property || Value ||
| {{rabbitmq.ROUTING_KEY}} | The routing key that will be used when sending the message |
| {{rabbitmq.EXCHANGE_NAME}} | The exchange the message was received from, or sent to |
| {{rabbitmq.CONTENT_TYPE}} | The contentType to set on the RabbitMQ message |
| {{rabbitmq.PRIORITY}} | The priority header to set on the RabbitMQ message  |
| {{rabbitmq.CORRELATIONID}} | The correlationId to set on the RabbitMQ message  |
| {{rabbitmq.MESSAGE_ID}} | The message id to set on the RabbitMQ message  |
| {{rabbitmq.DELIVERY_MODE}} | If the message should be persistent or not |
| {{rabbitmq.USERID}} | The userId to set on the RabbitMQ message  |
| {{rabbitmq.CLUSTERID}} | The clusterId to set on the RabbitMQ message |
| {{rabbitmq.REPLY_TO}} | The replyTo to set on the RabbitMQ message |
| {{rabbitmq.CONTENT_ENCODING}} | The contentEncoding to set on the RabbitMQ message |
| {{rabbitmq.TYPE}} | The type to set on the RabbitMQ message|
| {{rabbitmq.EXPIRATION}} | The expiration to set on the RabbitMQ message |
| {{rabbitmq.TIMESTAMP}} | The timestamp to set on the RabbitMQ message |
| {{rabbitmq.APP_ID}} | The appId to set on the RabbitMQ message |
{div}

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

...

Body

...

The

...

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.

Samples

To receive messages from a queue that is bound to an exchange A with the routing key B,

Code Block


h3. Samples

To receive messages from a queue that is bound to an exchange A with the routing key B,

{code}
from("rabbitmq://localhost/A?routingKey=B")
{code}

To

...

receive

...

messages

...

from

...

a

...

queue

...

with

...

a

...

single

...

thread

...

with

...

auto

...

acknowledge

...

disabled.

{
Code Block
}
from("rabbitmq://localhost/A?routingKey=B&threadPoolSize=1&autoAck=false")
{code}

To

...

send

...

messages

...

to

...

an

...

exchange

...

called

...

C

{
Code Block
}
...to("rabbitmq://localhost/B")
{code}

{include:Endpoint See Also}
Include Page
Endpoint See Also
Endpoint See Also