Search code examples
javaspring-bootapache-kafkaaxon

Axon Config - Kafka retry policies after @eventhandlers thrown exception


I've started to use Axon 4.3.1 (latest version) in my project and having a problem.

Where can I config the kafka retry policies after @eventhandler throw an exception?

OBS: I'm using SubscribingEventProcessor type as event processor (both projects). I'm using separate projects! Command model use mongo and publish events on Kafka. Query model consume events from Kafka (eventbus). In this way, using separate JVMs.

@processinggroup(event-processor) is configured to class with event-handler method. I'd like to have a config to Kafka auto retry after some time in error cases (from query model project).

Can I use some default Axon component? Could I use something like spring-retry or internal kafka configs itself?

I've found something like that (documentation):

https://docs.axoniq.io/reference-guide/configuring-infrastructure-components/event-processing/event-processors#error-handling

"Based on the provided ErrorContext object, you can decide to ignore the error, schedule retries, perform dead-letter-queue delivery or rethrow the exception."

How can I config (for example, schedule retries) on @eventhandler after errors?

Could you help me?

Thanks.


Solution

  • The current implementation of Axon's Kafka Extension (version 4.0-M2) does not support setting a retry policy when it comes to event handling.

    I'd argue your best approach right now is to set up something like that on Kafka, if that's even possible. Otherwise, forcing a replay of the events through Kafka would be your best approach.