Camel Spring Boot

Spring RabbitMQ

Send and receive messages from RabbitMQ using Spring AMQP.

What’s inside

Please refer to the above links for usage and configuration details.

Maven coordinates

<dependency>
    <groupId>org.apache.camel.springboot</groupId>
    <artifactId>camel-spring-rabbitmq-starter</artifactId>
</dependency>

Spring Boot Auto-Configuration

The starter supports 32 options, which are listed below.

Name Description Default Type

camel.component.spring-rabbitmq.allow-null-body

Whether to allow sending a message with a null body, which is then sent with an empty body. If false, the default message converter fails to send a null body with a MessageConversionException.

false

Boolean

camel.component.spring-rabbitmq.amqp-admin

The AmqpAdmin, such as a RabbitAdmin, that declares the exchanges, queues and bindings when auto-declaring (autoDeclare, autoDeclareProducer). The component uses the single AmqpAdmin in the registry when there is one; otherwise Camel creates a RabbitAdmin on the connection factory of the endpoint. The option is a org.springframework.amqp.core.AmqpAdmin type.

AmqpAdmin

camel.component.spring-rabbitmq.args

The arguments of the elements that are auto-declared and of the consumers, for all the endpoints (the arg. options of an endpoint add to them), each key with the prefix of its element: exchange., queue. and binding. for the exchange, the queues and their bindings; dlq.exchange., dlq.queue. and dlq.binding. for the dead letter exchange, queue and binding; and consumer. for the consumer arguments of basic.consume. The keys durable and autoDelete of the exchange, and durable, autoDelete and exclusive of a queue, set these flags (durable is true by default, the others false); the other keys are sent as arguments, such as queue.x-message-ttl=60000 for a message TTL of 60 seconds.

Object>

camel.component.spring-rabbitmq.auto-declare

Whether the consumer declares the exchange (of the exchangeType), its queues and their bindings to the exchange with the routing key, and the dead letter exchange and queue when they are configured, when it starts, and again on every new connection of the connection factory (except with a CachingConnectionFactory in CONNECTION cache mode). The exchange and the queues are durable and not auto-delete, unless the args option says otherwise. The amqpAdmin of the component declares them, else a RabbitAdmin that Camel creates.

true

Boolean

camel.component.spring-rabbitmq.auto-declare-producer

Whether the producer declares the exchange, the queues and their bindings, and the dead letter exchange and queue when they are configured, when it starts, as autoDeclare does for the consumer. Without the queues option, it declares a durable queue with a generated name: use skipDeclareQueue and skipBindQueue to declare the exchange only.

false

Boolean

camel.component.spring-rabbitmq.auto-startup

Whether the consumer starts its listener container, and so consumes messages, when it starts. If false, the listener container is started later, when the consumer is resumed.

true

Boolean

camel.component.spring-rabbitmq.autowired-enabled

Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc.

true

Boolean

camel.component.spring-rabbitmq.bridge-error-handler

Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions (if possible) occurred while the Camel consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. Important: This is only possible if the 3rd party component allows Camel to be alerted if an exception was thrown. Some components handle this internally only, and therefore bridgeErrorHandler is not possible. In other situations we may improve the Camel component to hook into the 3rd party component and make this possible for future releases. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored.

false

Boolean

camel.component.spring-rabbitmq.concurrent-consumers

The number of consumers: with DMLC, the consumers per queue; with SMLC, the consumers that each consume from all the queues. With more than one consumer, the messages are not processed in order.

1

Integer

camel.component.spring-rabbitmq.connection-factory

The Spring AMQP ConnectionFactory to connect to RabbitMQ with, such as a CachingConnectionFactory. It must be set on the component or the endpoint; the component uses the single ConnectionFactory in the registry when there is one. The option is a org.springframework.amqp.rabbit.connection.ConnectionFactory type.

ConnectionFactory

camel.component.spring-rabbitmq.dead-letter-exchange

The name of the dead letter exchange. Auto-declare (autoDeclare, autoDeclareProducer) declares it, of the deadLetterExchangeType, and declares the queues with it as their x-dead-letter-exchange argument, so that RabbitMQ dead-letters to it the messages that are rejected without requeue (see rejectAndDontRequeue) or that expire. Without auto-declare, this option is not used.

String

camel.component.spring-rabbitmq.dead-letter-exchange-type

The type of the dead letter exchange that auto-declare declares: direct, fanout, headers or topic.

direct

String

camel.component.spring-rabbitmq.dead-letter-queue

The name of the dead letter queue, which auto-declare declares as a durable queue and binds to the deadLetterExchange with the deadLetterRoutingKey. Only used together with deadLetterExchange.

String

camel.component.spring-rabbitmq.dead-letter-routing-key

The routing key for the dead letter exchange (the x-dead-letter-routing-key of the consumer queue). An auto-declared deadLetterQueue is bound to the dead letter exchange with this routing key: it is required for a direct or topic dead letter exchange, and not needed for a fanout or headers one.

String

camel.component.spring-rabbitmq.enabled

Whether to enable auto configuration of the spring-rabbitmq component. This is enabled by default.

Boolean

camel.component.spring-rabbitmq.error-handler

A custom Spring ErrorHandler that the listener container calls with the exceptions that the message listener throws, such as for a message that is rejected after the retries. By default the listener container uses a ConditionalRejectingErrorHandler. The option is a org.springframework.util.ErrorHandler type.

ErrorHandler

camel.component.spring-rabbitmq.header-filter-strategy

To use a custom org.apache.camel.spi.HeaderFilterStrategy to filter header to and from Camel message. The option is a org.apache.camel.spi.HeaderFilterStrategy type.

HeaderFilterStrategy

camel.component.spring-rabbitmq.ignore-declaration-exceptions

Whether the RabbitAdmin that Camel creates for auto-declaring ignores the exceptions of a declaration that fails, such as of a queue that exists with other arguments, so that the start does not fail: the consumer then binds and consumes such a queue by its name. Not used when the amqpAdmin option is set.

false

Boolean

camel.component.spring-rabbitmq.lazy-start-producer

Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing.

false

Boolean

camel.component.spring-rabbitmq.listener-container-factory

To use a custom factory for creating and configuring ListenerContainer to be used by the consumer for receiving messages. The option is a org.apache.camel.component.springrabbit.ListenerContainerFactory type.

ListenerContainerFactory

camel.component.spring-rabbitmq.max-concurrent-consumers

The maximum number of consumers, up to which a SimpleMessageListenerContainer (SMLC) adds consumers when the load increases. Not used with DMLC. If not set, the number of consumers stays at concurrentConsumers.

Integer

camel.component.spring-rabbitmq.maximum-retry-attempts

How many times the consumer retries a message that the route failed to process. The retries run in the listener container, without a redelivery by RabbitMQ. The first try is not counted, so 5 means up to 6 tries; 0 or less means no retry. After the last try, rejectAndDontRequeue decides what happens to the message.

5

Integer

camel.component.spring-rabbitmq.message-converter

A custom Spring AMQP MessageConverter that converts the message body to and from the body of a RabbitMQ message (org.springframework.amqp.core.Message). The default converter turns a received message with a text content type into a String, decoded with its content encoding, and any other message into a byte array; it sends a String as text, converts any other body to a byte array with the type converters, and never serializes or deserializes Java objects. The option is a org.springframework.amqp.support.converter.MessageConverter type.

MessageConverter

camel.component.spring-rabbitmq.message-listener-container-type

The type of the Spring AMQP listener container: DMLC (DirectMessageListenerContainer) calls the route on a thread of the RabbitMQ client, with concurrentConsumers consumers per queue; SMLC (SimpleMessageListenerContainer) calls it on its own consumer threads, each consuming from all the queues, and can add consumers up to maxConcurrentConsumers.

DMLC

String

camel.component.spring-rabbitmq.message-properties-converter

A custom MessagePropertiesConverter of this component that maps the Camel message headers to and from the MessageProperties of a RabbitMQ message (org.springframework.amqp.core.MessageProperties). The default maps the CamelSpringRabbitmq headers to the message properties, and the other headers that the header filter strategy allows to the headers of the RabbitMQ message. The option is a org.apache.camel.component.springrabbit.MessagePropertiesConverter type.

MessagePropertiesConverter

camel.component.spring-rabbitmq.prefetch-count

The prefetch count (basic.qos) of each consumer: how many unacknowledged messages RabbitMQ sends to a consumer at a time. A high value improves throughput; after a reconnect, up to this many messages per consumer may be delivered again. Not used with acknowledgeMode NONE.

250

Integer

camel.component.spring-rabbitmq.reject-and-dont-requeue

What the consumer does with a message that the route still failed to process after the retries. If true, it rejects the message without requeue, so that RabbitMQ dead-letters it when the queue has a dead letter exchange (see deadLetterExchange), and discards it otherwise. If false, Spring AMQP logs and drops the message: it is acknowledged (with acknowledgeMode AUTO), not requeued.

true

Boolean

camel.component.spring-rabbitmq.reply-timeout

The time in milliseconds that the producer waits for the reply to a request/reply (InOut) message, which it receives with RabbitMQ direct reply-to. When no reply arrives in time, the exchange fails with an AmqpReplyTimeoutException. 0 or a negative value waits forever: beware that every reply that never arrives then leaks memory. The option is a long type.

30000

Long

camel.component.spring-rabbitmq.retry

A custom StatelessRetryOperationsInterceptor, such as one built with RetryInterceptorBuilder.stateless(), that the listener container uses to retry a message that the route failed to process. When it is set, maximumRetryAttempts, retryDelay and rejectAndDontRequeue are not used. The option is a org.springframework.amqp.rabbit.config.StatelessRetryOperationsInterceptor type.

StatelessRetryOperationsInterceptor

camel.component.spring-rabbitmq.retry-delay

The delay in milliseconds between the retries of a message that the route failed to process (see maximumRetryAttempts), the same for every retry. A value of 0 or less does not remove the delay: the default delay of Spring, 1000 milliseconds, is used then.

1000

Integer

camel.component.spring-rabbitmq.shutdown-timeout

The time to wait for workers in milliseconds after the container is stopped. If any workers are active when the shutdown signal comes they will be allowed to finish processing as long as they can finish within this timeout. The option is a long type.

5000

Long

camel.component.spring-rabbitmq.test-connection-on-startup

Whether the consumers and producers test the connection to RabbitMQ when they start, by opening a connection with the connection factory: if that fails, the start fails, so that Camel does not start without a connection to RabbitMQ. Without it, a consumer starts while RabbitMQ is not available and keeps trying to connect.

false

Boolean