Axon microservices using Kafka and Spring Boot

I'm using spring boot Autoconfiguration and axon-Kafka in the following example https://github.com/marinkobabic/axon-kafka-example

My expectation was that the Autoconfiguration will, after setting all properties, will do the rest. The issue I faced is that

- trackingprocessor was not used by default
- SimpleEventBus is used as eventsource

So I decided to enable trackingprocessor by default and to create my custom eventbus as a component. Is this the correct approach?

When working using the distributed systems is the only possible option the AxonHub and AxonDB?

Why are AxonHub and AxonDB not open source even if the customers need to pay for it, which is absolutely fine for a good product?

Hi Marinko,

tracking event processors need to be activated, indeed. It’s a one-liner to activate that for all processors.

If you have JPA on the classpath, you will automatically get a Jpa based Event Store implementation. Axon falls back to SimpleEventBus when there is no JPA (or JDBC) available, and there is no EventStorageEngine defined.

Distributed implementations are also available in Axon itself, either using Spring Cloud, or JGroups for the CommandBus, and then Kafka or Spring AMQP for Events. A DistributedQueryBus is not yet available.

Hope this helps.
Cheers,

Allard

In my simple case no eventstore is used. All I tried is to send an even using the producer application. This worked perfectly after setting all the required configuration.

The consumer did not work that easy. All the configuration ware set, but it did still not work. Have no jdbc nor jpa on the class path. The idea is only to use the eventbus without eventstore. Because of the given environment the Axon Framework used the SimpleEventBus. SimpleEventBus is in this case the source of the events for the processors. The autoconfigured KafkaEventSource was not used at all.

What is the correct way to tell Axon to use KafkaEventSource as source of the events for the eventbus? Can this be done by configuration or is a custom eventbus the way to go?

You can check the sample application in the link in the previous post.

Many thanks for the feedback in advance.

Kind regards
Marinko

Hi Marinko,

You can configure your Processing Groups to use a specific ‘source’ for their events.

By default, Axon will use the EventStore/EventBus for this.

If you require those events to come from a AMQP queue or Kafka topic, you will have to tell that specific Processing Group to use that as the source of it’s events.

You can adjust this by either using the Configuration API provided by Axon or in a Spring environment by setting your properties.

The latter could make you end up with a line like this in your properties fiel:

axon.eventhandling.{name-of-processing-group}.source={bean-name-of-source}

The ‘name-of-processing-group’ can be set for your Event Handling Components by either (1) using the Configuration API again and specifying it yourself or by (2) setting the ‘@ProcessingGroup({name-of-processing-group})’ on your Event Handling classes. I’d argue the latter is the easiest approach, as you’re pointing out you’re using Spring Boot.

The ‘bean-name-of-source’ in this scenario is the name of your KafkaMessageSource.

Lastly I’d like to note that AxonDB and AxonHub aren’t requirements to run your applications distributed.

They just make your life a hell of a lot easier.

If you want any information on how to use them, feel free to contact us at AxonIQ.

Apart from that, I hope this helps you out Marinko!

Cheers,

Steven

Hi Steven

The documentation should be adjusted so that this is clear to everybody. Have made the changes before your post and all works out of the box. Many thanks anyway.

I’m missing an architecture overview in generally of the Axon Framework. Why does the eventbus have a method OpenStream. Bus is not a repository. Trackerprocessor what? Processinggroup? After digging the code I have now a better understanding but this does not help others. A picture with all the components would be helpful at all.

Many thanks
Marinko

Hi Marinko,

We agree that the reference guide has sadly been lacking attention, a lot.

We are hard at work to making all the necessary adjustments to clarify a lot of the process around using the framework.

Thus, many thanks for pointing out your concern in this space, that signals we are working in the right spot at this point.

Feel free to introduce any issues you might have or things you are missing in the Reference Guide here.
That would help us out tremendously.

Again, thanks for voicing your concern. we’ll do our best to ensure the journey will be simpler in the future.

Kind regards,

Steven

PS I have created an issue describing the exact problem you had with setting the right message source here.

Many thanks Steven :slight_smile: