Kevin Macaraeg
Kevin Macaraeg

Reputation: 49

Message only gets published to one queue in a RabbitMQ Fanout exchange (java)

So, I have 2 queues, outboundEmailQueue and storeEmailQueue:

<rabbit:queue name="outboundEmailQueue"/>
<rabbit:queue name="storeEmailQueue"/>

binded to a fanout exchange called integrationExchange:

<rabbit:fanout-exchange name="integrationExchange" auto-declare="true">
    <rabbit:bindings>
        <rabbit:binding queue="outboundEmailQueue"/>
        <rabbit:binding queue="storeEmailQueue"/>
    </rabbit:bindings>
</rabbit:fanout-exchange>

the template:

<rabbit:template id="integrationRabbitTemplate"
    connection-factory="connectionFactory" exchange="integrationExchange"
    message-converter="jsonMessageConverter" return-callback="returnCallback"
    confirm-callback="confirmCallback" />

how I am sending an object to the exchange:

integrationRabbitTemplate.convertAndSend("integrationExchange", "", outboundEmail);

However, the message only gets published to storeEmailQueue:

enter image description here

enter image description here

What is wrong with my configuration? Why is the message not being queued to outboundEmailQueue?

Upvotes: 0

Views: 912

Answers (2)

Olivier
Olivier

Reputation: 2681

From the screen captures, it seems your configuration is ok and the message is reaching both queues. But the consumer configuration on each queue is not the same:

  • storeEmailQueue has consumer ack configured
  • outboundEmailQueue has autoack configured

If you have a doubt:

  • check the bindings section of either the exchange or the queues to confirm the link is there (but again, from your screen captures, seems likely to be present)
  • stop the consumers and push a message to the exchange, you should see the message ready count (and total count) increase on both queues.

Upvotes: 1

Gagan Bansal
Gagan Bansal

Reputation: 323

I created the same example and its working fine, message is being added to both the queue, But I configure through annotations instead of the XML. If you want the annotations solution, please follow below link:

https://stackoverflow.com/questions/45803231/how-to-publish-messages-on-rabbitmq-with-fanout-exchange-using-spring-boot

Upvotes: 0

Related Questions