Shut Axon gracefully down

Hi,

I am using the axon-spring-boot-starter 4.1.1 (without the axon-server-connector) and wonder if there is something like a graceful shutdown option for Axon.

Originally I assumed that something like the following would work:

`

final ConfigurableApplicationContext applicationContext = SpringApplication.run( MyApplication.class );

applicationContext.stop( );

`

It seems that this is not enough, as some non-daemon threads from the EmbeddedEventStore remain. Therefore I tried the following:

`

final ConfigurableApplicationContext applicationContext = SpringApplication.run( MyApplication.class );

applicationContext.stop( );
applicationContext.getBean( EmbeddedEventStore.class ).shutDown( );

`

This seems to work, but I am not sure whether this is a good way. Is this correct? Or is there another way to terminate Axon?

Thank you and best regards

Nils

Hi Nils,

For your current scenario, it’s fine to call the EmbeddedEventStore#shutdown() method by hand.
Ideally though, Axon Framework would deal with the shutdown scenario nicer.
We’ve marked this desire in an issue, which you can find here.

So, again, for now my hunch is your approach is fine.
But, we are on point to providing a more graceful shutdown.

Cheers,
Steven