spring-bootapache-kafkaaxonsaga

Using non-axon kafka events in axon sagas


I have several microservices using kafka and not all of them use axon framework. My idea is that I want to handle some events from non-axon microservices and use them in my sagas. Can "extension-kafka" help me? As far as I understand, I will need to implement custom KafkaMessageConverter. What other difficulties can I face? Perhaps there are examples with a similar configuration?


Solution

  • There is an example project, where I added a producer of Kafka Records, legacy producer. Then there is the legacy consumer in the same project. Based on the information from the event, it send a command.

    As a saga is underneath a specific type of event processor, that should work with saga's to. If the same saga's need to handle both events from Axon, and the records from Kafka, you likely need to combine them in the source used.

    You might want to consider the same approach as in the demo project, sending commands based on the records from Kafka, as it needs less custom parts. It's also possible to not use the extension, and use Spring Kafka, to get the data from the Kafka record, and send a command based on that.

    If you don't use Cloud Events with Kafka and would like to use to extension, you indeed need to implement the KafkaMessageConverter to create proper Axon Events, from the Kafka Records.

    In short, it depends on your use case, but there are many options. It should not be hard to get it to work.