0

I would like to know what happens to the already polled events on a gracefull shutdown eg. a SIGTERM was received.

  1. All events from the poll will be handled and the offset will be commited, bindings will be unregistered
  2. The current event will be handled, the offset committed and the remaining events discarded, bindings will be unregistered
  3. ?

If option one is the case, what would be the best/simplest solution to implement the option two behaviour? We use manual acks.

For example: Implement the SmartLifecyle interface where we ack our events and react to a flag which will be set in the stop() methode which causes a .nack(0) call (discard all remaining events) while processing the next event. The next poll should not happen due to the isRunning() condidion in KafkamessageListenerContainer#970 which will be set to false through the lifecycle interface

Versions:

Spring Boot 2.3.1, Spring Cloud Horsham.SR6 (Spring Cloud Starter Stream Kafka 3.0.6)

Thanks!

Chr3is
  • 387
  • 5
  • 21
  • So what's the question? Your example solution sounds correct - does it not work? – Gary Russell Sep 14 '20 at 14:03
  • @GaryRussell not yet, I just wanted to know if the assumption is correct that all events from the poll will be handled before the whole application will be shut down. Seems like the approach with the lifecycle interface is going to fit the most. – Chr3is Sep 14 '20 at 14:57
  • 1
    Yes; your assumption is correct; you will need to ensure that any `Lifecycle` components called from the listener are in earlier phase than the listener (so they are stopped later), you may also want to suspend in `stop()` until the current record is processed (or for a short timeout). – Gary Russell Sep 14 '20 at 15:12

0 Answers0