javaspring-bootrabbitmq

Spring boot using undefined for x-queue-type instead none


Dependencies

java: 17
spring-boot: 3.2.12
spring-cloud-starter-stream-rabbit: 4.1.2
bitnami/rabbitmq: 3.13.7-debian-12-r2

Error

ERROR [,,,] 1 --- [.43.83.237:5671] o.s.a.r.c.CachingConnectionFactory       : 
Shutdown Signal: channel error; protocol method: #method<channel.close>(reply-code=406, reply-text=PRECONDITION_FAILED -
inequivalent arg 'x-queue-type' for queue 'xyz_sub_topic.xyz_sub_group' in vhost '/': 
received the value 'undefined' of type 'longstr' but current is none, class-id=50, method-id=10)

RabbitMQ

Using bitnami/rabbitmq:3.13.7-debian-12-r2 in k8s. But When I run same app locally with local rabbitmq (rabbitmq:3-management), it is working fine.

Another difference is - RabbitMQ in k8s cluster using self signed tls certificate. Passing arguments like below

-Dspring.rabbitmq.ssl.enabled=true
-Dspring.rabbitmq.ssl.key-store=file:/tmp/mdsp-ssl.pfx
-Dspring.rabbitmq.ssl.key-store-password=changeit
-Dspring.rabbitmq.ssl.key-store-type=PKCS12
-Dspring.rabbitmq.ssl.trust-store=file:/tmp/cacerts

Passing configurations

spring.cloud.function.definition : podMetaDataSupplier;abcSupplier;receiveAbcMessage;receivePodEventMessage;receiveTenantProvisionMessage
spring.cloud.stream.bindings.abcSupplier-out-0.destination : xyz_sub_topic
spring.cloud.stream.bindings.podMetaDataSupplier-out-0.destination : xyz-pod-events-queue
spring.cloud.stream.bindings.receiveAbcMessage-in-0.destination : xyz_sub_topic
spring.cloud.stream.bindings.receiveAbcMessage-in-0.group : xyz_sub_group
spring.cloud.stream.bindings.receivePodEventMessage-in-0.destination : xyz-pod-events-queue
spring.cloud.stream.bindings.receivePodEventMessage-in-0.group : xyz-pod-events-group
spring.cloud.stream.bindings.receiveTenantProvisionMessage-in-0.destination : provisioning-notification-topic
spring.cloud.stream.bindings.receiveTenantProvisionMessage-in-0.group : provisioning-notification-group
spring.cloud.stream.bindings.tenantDeletionSupplier-out-0.destination : provisioning-notification-topic

Solution

  • Somebody answered this question but I cant see that answer anymore. Not sure what happened. I followed one of the solution from that answer and it worked. I dont remember other solutions.

    Adding below properties will stop creating queues and use existing queues.

    spring.cloud.stream.rabbit.bindings.receiveAbcMessage-in-0.consumer.bindQueue: false
    spring.cloud.stream.rabbit.bindings.podMetaDataSupplier-out-0.consumer.bindQueue: false
    spring.cloud.stream.rabbit.bindings.receivePodEventMessage-in-0.consumer.bindQueue: false
    spring.cloud.stream.rabbit.bindings.receiveTenantProvisionMessage-in-0.consumer.bindQueue: false
    

    Reference : https://docs.spring.io/spring-cloud-stream-binder-rabbit/docs/current/reference/html/spring-cloud-stream-binder-rabbit.html