Sometimes, it is useful to just have an idea of the messages that are really traveling through a broker by just logging all of them to the standard output.
It is possible to trace those messages using a simple application provided with the RabbitMQ Java client.
To run this recipe, you need to have RabbitMQ up and running on the standard port 5672
and the RabbitMQ Java client library.
RabbitMQ includes a tracing utility in the Java client library that you can put in action by following these steps.
./runjava.sh com.rabbitmq.tools.Tracer
5673
. For this recipe, we will use another Java tool included in the Java client library, by invoking:./runjava.sh com.rabbitmq.examples.PerfTest -h amqp://localhost:5673 -C 1 -D 1
The Java tracing tool is a simple AMQP proxy; by default, it listens on port 5673
and forwards all the requests to the RabbitMQ broker listening by default on localhost
at port 5672
.
All the messages produced or consumed, as well as the AMQP operations, are all logged to a standard output.
To run the recipe at step 4 of the previous steps we have used another tool that is included in the RabbitMQ Java client library that can be used to perform a stress test with RabbitMQ.
In our case, we have just limited it to produce one message (-C 1
) and consume it (-D 1
).
It's possible to pass some more parameters to the Java tracing program using the following code:
./runjava.sh com.rabbitmq.tools.Tracer listenPort connectHost connectPort
In the preceding code listenPort
refers to the port where the tracer is listening (default: 5673
), connectHost
/connectPort
(default: localhost/5672
) are the host and the port where it connects to and forwards the requests it receives.
You can find all PerfTest
available options using:
./runjava.sh com.rabbitmq.examples.PerfTest --help
You can find the documentation of the Java tracing tool and PerfTest at http://www.rabbitmq.com/java-tools.html.