Joining, leaving or timing out triggers reassignment, and no member consumes while it happens.
props.put(ConsumerConfig.SESSION_TIMEOUT_MS_CONFIG, 45_000);
props.put(ConsumerConfig.HEARTBEAT_INTERVAL_MS_CONFIG, 3_000);
props.put(ConsumerConfig.MAX_POLL_INTERVAL_MS_CONFIG, 300_000);
props.put(ConsumerConfig.MAX_POLL_RECORDS_CONFIG, 100);
Processing a batch for longer than max.poll.interval.ms
makes the broker assume the consumer is dead, and it rebalances -
which is the usual cause of a consumer that "keeps restarting".
Run this yourself in the Online Java Compiler, spin up a live REST API in the API Sandbox, or practise with Java interview questions.
Published 2026-08-11