I'm a maintainer of the JavaLite open source project. One part of it is called Async, and it is a simplified front-end for the Apache ActiveMQ Artemis broker. It exists in order to make it easier to embed Artemis in memory of the process and also adds a layer of convenience to process "Commands". We have used it in production for many years with almost no issues.
However, the JavaLite project itself has tests that start/stop the broker multiple times and use different instances for different tests. Here's the source code of Async
and the source code of tests.
As you can see, the test creates a new instance of the broker, uses it, then stops it.
Here's the start and stop methods.
Now to the question. Generally the build running tests succeeds without issues on both my laptop and an older CI environment. My laptop and previous CI servers never had any issues with it. However, we are building a new CI server, and this test fails there with random number of logical errors (test conditions). Sometimes it succeeds too. Everything is identical between machines where it succeeds and fails, except hardware. The box where it fails has only two CPU cores (my laptop has 12 cores).
So, in the test AsyncSpec, we create, start and stop the broker and it seems that some data is randomly bleeding across different instances of the broker.
What is the best/cleanest way to create/start/stop/destroy the Artemis embedded server in the same VM without conflicts across multiple instances?