How do I find out which exchange routed a message last?

Viewed 56

We are intending to build up a one way network of exchange-to-exchange bindings. Our requirement is to attach the route a message took to its header, but there seems to be no way to find out which exchange handled a message last.

I already tried looking up the information using the tracing functionality and there also exists a plugin that subscribes to the internal basic.publish event. Yet, all these ways just give me the exchange of first entry.

I even took a look at the rabbitmq-server source code and it seems like there is no possible extension point inside the routing function (see headers exchange routing for example). I am not an Erlang dev, so maybe there is an Erlang way of intercepting/extending functions to be called?

Example

         +---------+
         |         |
         |   POE   |
         |         |
         +--+--+---+
            |  |
+-------+   |  |    +-------+
|       |   |  |    |       |
|  EX1  +---+  +----+  EX2  |
|       |           |       |
+--+----+           +---+---+
   |                    |
   |                    |
   |                    |
+--+----+           +---+---+
|       |           |       |
|  QU1  |           |  QU2  |
|       |           |       |
+-------+           +-------+

For a message that ends up in QU2 we would like to have a header field like this:

{...
    x-route, ["POE", "EX2"]
}
1 Answers

This could probably be accomplished with a RabbitMQ plugin but it would be difficult to do: a channel interceptor would have to effectively do a part of the routing to determine the "last" exchange. There could be more than one "last" exchange, as well.


NOTE: the RabbitMQ team monitors the rabbitmq-users mailing list and only sometimes answers questions on StackOverflow.

Related