Aides RabbitMQ
Some pointers
- AMQP specification: version 0.9.1
- RabbitMQ versus AMQP version 0.9.1: Protocol Extensions and Specification Differences
- RabbitMQ server: manual pages
- JAVA Client API: guide, Javadoc
- Concept of virtual host: guide with the section User Management of the rabbitmqctl command manual.
- RabbitMQ's feature direct reply-to for RPC calls.
- JAVA Client for the RabbitMQ HTTP API: Hop, Management HTTP API
Does RabbitMQ provide disconnection detection?
- Yes, in the form of periodically exchanging heartbeats. For more information, please refer to documentation page "Detecting Dead TCP Connections with Heartbeats"
Commands rabbitmq-server
and rabbitmqctl status
are working properly, but not the JUnit tests (connection refused)
May be your computer is slow. In JUnit tests, try to sleep for
instance 10 seconds before and after
command rabbitmq-server.
Checking/debugging AMQP infrastructure with HTTP API of rabbitmq_management plugin
When installing RabbitMQ, we have enabled the
plugin rabbitmq_management. We use it in the
tutorials: e.g., in the JUnit test
class TestScenario of the tutorial
step ExemplesRabbitMQ/RabbitMQ-Tutorial-Step1:
The documentation of the HTTP API is available
online.
...
public class TestScenario {
private static Client c;
@BeforeClass
public static void setUp() throws IOException, InterruptedException, URISyntaxException {
...
// creation of the HTTP client to the rabbitmq_management plugin
c = new Client("http://127.0.0.1:15672/api/", "guest", "guest");
}
@Test
public void test() throws IOException, TimeoutException, InterruptedException, ExecutionException {
Recv recv = new Recv();
// assert that the queue exists
Assert.assertNotNull(c.getQueues().stream().filter(q -> q.getName().equals(Send.QUEUE_NAME)));
...
}
}
Checking/debugging AMQP code when no stack trace is printed in order to see the problem
Sometimes, when you write and debug your code, the error message
is rather short and does give some clues to solve the problem:
e.g., "[AMQP Connection 127.0.0.1:5672] WARN
com.rabbitmq.client.impl.ForgivingExceptionHandler - An
unexpected connection driver error occured (Exception message:
Socket closed)".
You can try to execute the JUnit test in your IDE, for instance
in Eclipse. The stack trace should be displayed.
Why? This is so because you execute a multi-threaded application
and the stack trace is not printed in the console because the
flush of the output did not have the time to be executed in the
console.
What can be done? In your JUnit code, debug by catching the
exception and printing the stack trace using
method Exception::printStackTrace().
$Date: 2020-11-05 08:19:23 +0100 (jeu. 05 nov. 2020) $