How to properly reset/shutdown axon between integration tests

Hi everyone!

We’re running integration tests which dirty the Spring context between test runs with:

@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_EACH_TEST_METHOD)

This works. BUT: after each test is run, Axon will take an additional 1 minute for all of the connections, threads, etc to time out, after each test.

How do I properly reset/shutdown the Spring context with Axon running in it between tests?

I already tried applicationContext.getBean( but this let’s the test fail.

Thanks, Martin

Hi Martin,

Axon as of 4.3 employees a grace full shutdown solution, making sure everything is closed and unsubscribed at the right time.
This solution should automatically kill everything at the end of an integration test as well, although it indeed might need some time.

So, without knowing the version you are on, I would recommend to move over to the latest (currently 4.4.2) to benefit from this.
If you already are on 4.3 or higher, then that warrants an investigation in more detail for which more information than “all of the connections, threads, etc”.

Trusting this will help you further Martin!


PS. It is important to note that this mailing list will be discontinued as specified in this thread.
Instead of this mailing list we have moved to use a forum style of communication, at

Hope to see you there!