I'm writing a kafka listener which should just forward the messages from a topic to a jms queue. I need to stop processing new messages only for a custom exception JmsBrokerConnectionException
but i want to continue processing new messages for any other exceptions (ie invalid data) and send error messages to a DLT.
I am using spring-kafka 2.2.7 and cannot upgrade it.
I have currently a solution which uses:
SeekToCurrentErrorHandler
(configured with 0 retries and aDeadLetterPubishingRecoverer
)- a retry template used in the
@KafkaListener
method configured withInteger.MAX_VALUE
retries, which retries only forJmsBrokerConnectionException
- MANUAL_IMMEDIATE ack
The solution seems to do the job but it has the drawback that, for long outages of the jms broker, it would cause a rebalance each max.poll.interval.ms
(ie 5 mins).
The question:
Is it a good idea to let max.poll.interval.ms
expire and have a group rebalance to handle error conditions for which you want to stop message consumption?
I don't have high-throughput requirements. The input topic has 10 partitions and i will have 2 consumers. I know there are other solutions using stateful retry or pausing/resuming the container, but i'd like to keep using the current solution unless i am missing any major drawbacks about it.