Module CSC7321—CSN: Middleware and software architecture for Internet distributed applications

Portail informatique

Aides RabbitMQ

Some pointers

Does RabbitMQ provide disconnection detection?

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:
... 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("", "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))); ... } }
The documentation of the HTTP API is available online.

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] 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) $