Custom DLX options in rabbitmq binder

Viewed 293

I'm using spring-cloud-stream for communicating between microservices. I have the following predefined setup in the rabbit mq broker.

"first" -> exchange of type Topic which is bound to Queue (name="user.create",x-dead-letter-exchange="first.dlx")
"first.dlx" -> dead letter exchange of type Topic

and the following configuration file:

spring:
    cloud:
        stream:
            bindings:
                consumer-input:
                  group: user.create
                  destination: first
                  contentType: application/json
                  binder: rabbit
            binders:
                rabbit:
                  type: rabbit
            rabbit:
                bindings:
                  consumer-input:
                    consumer:
                      acknowledgeMode: manual
                      declareExchange: false
                      queueNameGroupOnly: true 
                      bindQueue: false
                      deadLetterExchange: first.dlx
                      autoBindDlq: true
                      deadLetterRoutingKey: user.create.dlq

and when I start the application says :

[AMQP Connection 127.0.0.1:5672] ERROR o.s.a.r.c.CachingConnectionFactory - Channel shutdown: channel error; protocol method: #method<channel.close>(reply-code=406, reply-text=PRECONDITION_FAILED - inequivalent arg 'type' for exchange 'first.dlx' in vhost '/': received 'direct' but current is 'topic', class-id=40, method-id=10)

because rabbit mq try to declare dlx of type "direct". Here is the link of the repo.

so my question ... is there any way to tell rabbit mq to declare dlx of other type than "direct" something like property name: "deadLetterExchangeType: topic"? or not to declare dlx at all.

Any other suggestion will be very helpful.

1 Answers

It is not currently possible to define the DLX exchange type or prevent its declaration. Please open an issue against the binder.

Just allowing the type to be specified might not be enough, since it might have other incompatible arguments. We should probably add declareDlx, similar to declareExchange.

Related