Search code examples
rubyrabbitmqamqp

How to detect the source of queue message?


I'd like to know what are the publishers that publish a message that arrives at a specific queue in RabbitMQ. I know what exchange forward messages to the queue, but in my exchange there are many publishers and only few of them send message with the routing key that goes to this queue.

Is there a way to do that?

Thanks


Solution

  • There isn't anything in the RabbitMQ spec that would include the original publisher of a message. I'm starting to have all publishers include X- headers for metadata that I would possibly like to use for accounting purposes. Things generally worth including:

    • X-Publishing-Host - hostname of box
    • X-Publishing-Server - name of service publishing
    • X-Publishing-Time - epoch timestamp of publish

    With those your consumer can start to figure out a bit more of what happened. I include the time so that I have some idea as to the latency between publishing and working on the message. If you can as well, include the version of the software that is publishing although you may get close enough with the timstamp.