0
votes

I'm using spring boot 2.1.7.RELEASE and spring-kafka 2.2.8.RELEASE.And I'm using @KafkaListener annotation to create a consumer and I'm using all default settings for the consumer.

Now, In my consumer, the processing logic includes a DB call and I'm sending the record to DLT if there is an error/exception during processing.

With this setup, If the DB is down for few mins because of some reason, I want to pause/stop my consumer from consuming more records otherwise it keeps on consuming the messages and will get the DB exception and eventually fill up my DLT which I don't want to do unless the DB is back (based on some health check).

Now I've few questions here.

  1. Does spring-kafka provide an option to trigger infinite retry based on the exception type (in this case a DB exception but I want to add few more types of exception based on my consumer logic)
    1. Does spring-kafka provide an option to trigger the message consumption based on a condition?
1

1 Answers

1
votes

There is a ContainerStoppingErrorHandler but it will stop the container for all exceptions.

You would need to create a custom error handler that stops (or pauses) the container after a specific failure as well as some mechanism to restart (or resume) the container.