1

I think this is a fairly common problem.

I'm using C# and Rabbit MQ client. I have a publisher sending a message to an exchange. The publisher queue and subscriber queues are all bound to the exchange via a routing key. When the publisher sends a message to the Exchange, all the subscriber queues receive the message as expected, however the publisher queue also receives the message.

is there a good pattern that can be employed to prevent this?

  • i know this isn't an answer... the best to way prevent this is to avoid the design that you have. so, what's the purpose of having the producer also be a consumer of the same type of message? knowing that may help lead to better designs. – Derick Bailey Dec 01 '15 at 20:30
  • I think there might a some issue with your design. Ideally the publishers should push to a particular queue & the subscribers should listen from the same queue. Why separate queues? – underdog Dec 11 '15 at 06:20
  • chech your routing keys. check exchange type, it may equal to "fanout". – Azat Nugusbayev Dec 22 '15 at 07:41

1 Answers1

0

When you send a message, you give the message an Id. Normally a GUID. You could track which messages you send, and if a message you receive is one you know you have sent you could discard it.

However, as Derick said, the best bet is just not to do this.

chris.ellis
  • 883
  • 6
  • 10