0
votes

I'm using Axon version (3.3) which seamlessly supports Kafka with annotation in the SpringBoot Main class using

@SpringBootApplication(exclude = KafkaAutoConfiguration.class)

In our use case, the command side microservice need to pick message from kafka topic rather than we expose it as Rest api. It will store the event in event store and then move it to another kafka topic for query side microservice to consume.

Since KafkaAutoCOnfiguration is disabled, I cannot use spring-kafka configuration to write a consumer. How can I consume a normal message in Axon?

I tried writing a normal Kafka spring Consumer but since Kafka Auto COnfiguration is disabled, initial trigger for the command is not picked up from the Kafka topic

1

1 Answers

1
votes

I think I can help you out with this.

The Axon Kafka Extension is solely meant for Events. Thus, it is not intended to dispatch Commands or Queries from one node to another.

This is very intentionally, as Event messages have different routing needs apposed to Command and Query messages. Axon views Kafka a fine fit as an Event Bus and as such this is supported through the framework. It is however not ideal for Command messages (should be routed to a single handler, always) or Query messages (can be routed to a single handler, several handlers or have a subscription model).

Thus, I you'd want to "abuse" Kafka for different types of messages in conjunction with Axon, you will have to write your own component/service for it. I would however stick to the messaging paradigm and separate these concerns.

For far increasing simplicity when routing messages between Axon applications, I'd highly recommend trying out Axon Server. Additionally, here you can hear/see Allard Buijze point out the different routing needs per message type (thus the reason why Axon's Kafka Extension only deals with Event messages).