Search code examples
javaspringspring-bootrabbitmqspring-camel

Use spring rabbitmq camel in single active consumer mode


RabbitMQ has a single active consumer mode, where only one out of several connected listeners get messages from a queue

to have only one consumer at a time consuming from a queue and to fail over to another registered consumer in case the active one is cancelled or dies

Is there a way to automatically enable this via the from definition for camel 4.4?

Previously, passing the &exclusiveConsumer=true parameter worked, but this seems to be no longer supported for the SpringRabbitMQComponent component.


Solution

  • To activate, you can use

    arg.queue.x-single-active-consumer=true
    

    in the queue's definition. source on github, with getQueueArgs.

    As an alernative, you can use &exclusive=true in the from definition for exclusive consumers.