I’ve played a bit with event schedulers. I was wondering what the best way to configure event schedulers through the configuration API and handle their life cycle is?
I’ve setup a standalone application via DefaultConfigurer, created a SimpleEventScheduler and registered it as component in the configuration. So far no problems just using it, e.g. in a Saga.
The problem comes when the application ends and wants to shutdown. The executor service used in the simple event scheduler doesn’t terminate because its shutdown method is never called.
That leads to the question, how axon is looking at managed objects if using java configuration? I can think of several solutions:
1.) Give axon components a life cycle so that they can be stopped with the configuration just as module configurations are.
2.) Allow a module configuration to create and register components in order to control their life cycle
3.) Make the event scheduler an important concept in the configuration just as event bus or command bus are and manage the life cycle there.
Sure, this problem goes away if using e.g. a DI container which can manage the life cycle of application specific services. And maybe this is also indicates that you have decided that axon should stay out of the way in managing life cycles other than axon core components.
What do you think?