Axon without Spring Boot (with e.g. Ktor)

Hey guys,

I’m not a huge fan of Axon with annotations and would like to write a new project without them. Ideally I would like to write it in Kotlin in Ktor rather than Spring Boot. Does anyone have any experiences, code samples, tips? I haven’t found much in Axon docs about using it without annotations.

Thanks in advance!

PS: I’ve just noticed that at least some of Axon annotations are indendent of Spring. Has anyone tried using Axon without Spring and could share his thoughts/experiences?

We’re using Axon w/ Kotlin and WebFlux. I find the Axon and WebFlux annotations to be quite tasteful, and WebFlux has functional routing definitions (I think there are better docs but those came up first in Google).

The thing that drives me crazy is JPA/Hibernate and given some free time I would swap them out for a more Kotlin-y SQL adapter. We’ve had to basically pretend we’re writing Java, with empty constructors and lateinit, to make it halfway usable.

Thanks @Joel. I would like to avoid Hibernate as well, I’m not a fan of this tool at all to be honest :slight_smile:

The thing is that I would like to avoid Spring entirely and go for another framework (currently assessing Ktor). The thing is though that without Axon’s plugin for Spring I get no autowiring and autocreation of Axon’s classes and I need to write stuff like:

CommandBus commandBus = new SimpleCommandBus();

// to subscribe a handler:
commandBus.subscribe(MyPayloadType.class.getName(), myCommandHandler);

The worst thing is that there is no info on how to do this in the current documentation and I need to go through the horribly outdated one: https://legacy-docs.axoniq.io/reference-guide/v/2.4/command-handling.html 

Hi Krystian,

here is where you can find it in the current documentation:
https://docs.axoniq.io/reference-guide/configuring-infrastructure-components/command-processing

Basically, just use the DefaultConfigurer class to get started. Axon will initialize all components using sensible defaults and allow you to customize the configuration as well. All code examples in the reference guide are available for Spring Boot as well as “plain configuration”.

Kind regards,

Hi Allard,

Thanks for the direct link. I missed it when I was initally looking at the docs.

What I struggled with for quite a while though is the fact that after you build your configuration, you also need to start it:

val config: Configuration = configurer.buildConfiguration()
config.start()

Is it described anywhere in the docs? I found it by following the source code of Axon.

It would be great if there was a complete example on how to wire an Axon app properly without Spring Boot.

Thanks again for help!

Cheers
Krystian

Hi Krystian,

I don’t know, if this could help you, but I made a showcase on how to configure axon for JavaEE or MicroProfile on Quarkus:
showcase-quarkus-eventsourcing

It is in Java, not Kotlin.
It is just a small example, without saga e.g.
And it has an extra abstraction for „axon outside the boundary“, that may be more complex than necessary.

However, there is a class „AxonConfiguration“, that attaches everything to the config and provides the necessary services (commandgateway…)

I’m not sure, if this is of any help for you.

Cheers. JohT.

1 Like

Hi Johnny,

This is a very helpful showcase. Thanks a lot for sharing it!

Best wishes
Krystian