Debugging RabbitMQ's messages

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.

Getting ready

To run this recipe, you need to have RabbitMQ up and running on the standard port 5672 and the RabbitMQ Java client library.

How to do it...

RabbitMQ includes a tracing utility in the Java client library that you can put in action by following these steps.

  1. Download the latest version of the RabbitMQ Java client library from http://www.rabbitmq.com/java-client.html.
  2. Unpack it and enter its directory.
  3. Run the Java tracer by running:
    ./runjava.sh com.rabbitmq.tools.Tracer
    
  4. Run the Java client that is to be debugged and that connects to port 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
    

How it works...

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).

Note

The tracing tool is available in the Java client API only.

There's more...

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

See also

You can find the documentation of the Java tracing tool and PerfTest at http://www.rabbitmq.com/java-tools.html.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset