I try to migrate my Apache Camel application from component RabbitMQ to component Spring RabbitMQ. Unfortunately some defaults are changed. One is the durable
property for queues (see Durability), which is now false
by default.
Code
from(springRabbitmq("my_exchange")
.routingKey("my_routing_key")
.queues("q_my_queue")
.autoDeclare(true))
Versions
Logs
Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method<channel.close>(reply-code=406, reply-text=PRECONDITION_FAILED - inequivalent arg 'durable' for queue 'q_my_queue' in vhost '/': received 'false' but current is 'true', class-id=50, method-id=10)
Research
I read SpringRabbitMQEndpointConsumerBuilder
, but there is no method for durable
.
I read AdvancedSpringRabbitMQEndpointConsumerBuilder
, but there is no method for durable
.
I read AUTO DECLARE EXCHANGES, QUEUES AND BINDINGS
The elements can be configured using the multi-valued
args
option.For example to specify the queue as durable and exclusive, you can configure the endpoint uri with
arg.queue.durable=true&arg.queue.exclusive=true
.
but I want to use endpoint DSL.
I read args
Specify arguments for configuring the different RabbitMQ concepts, a different prefix is required for each element: arg.consumer. arg.exchange. arg.queue. arg.binding. arg.dlq.exchange. arg.dlq.queue. arg.dlq.binding. For example to declare a queue with message ttl argument: args=arg.queue.x-message-ttl=60000. The option is a:
java.util.Map<java.lang.String, java.lang.Object>
type. The option is multivalued, and you can use the args(String, Object) method to add a value (call the method multiple times to set more values). Group: advanced
and tried
from(springRabbitmq("my_exchange")
.routingKey("my_routing_key")
.queues("q_my_queue")
.autoDeclare(true)
.advanced()
.args("arg.queue.durable", true))
and
from(springRabbitmq("my_exchange")
.routingKey("my_routing_key")
.queues("q_my_queue")
.autoDeclare(true)
.advanced()
.args("arg.queue.durable", "true"))
but I got the same error.
Question
How can I set the property durable
for a queue?
Did you try this?
from(springRabbitmq("my_exchange")
...
.args("queue.durable", "true"))