Using Kotlin suspend fun with @CommandHandler, @EventSourcingHandler & @EventHandler annos?

Just wondering when I’ll be able to use Kotlin suspend fun methods with @CommandHandler, @EventSourcingHandler and @EventHandler annotations.

Will we expect to see full Kotlin coroutine support in Axon 5?

Not soon at least. We do probably move to being more reactive in Axon Framework 5, making it easier for the Kotlin extension to support such things. At the moment one of the reasons we can’t is the way transactions are handled. As we depend on ThreadLocal, it’s near impossible to neatly integrate with coroutines, without resorting to blocking, which defeats the purpose.

I feared as much – :confused: . I’ve never really liked the AggregateLifecycle.apply(..) strategy due to its obvious use of ThreadLocal. Seems like a good alternative would be to receive an injected method argument instead so there were no statics involved.

1 Like