private final String id;
private final String topic;
private final Consumer<K, V> consumer;
- private final PollIntervalAwareConsumerRebalanceListener pollIntervalAwareRebalanceListener;
- private final RecordHandler<K, V> handler;
+ private final PollIntervalAwareConsumerRebalanceListener rebalanceListener;
+ private final RecordHandler<K, V> recordHandler;
private final Lock lock = new ReentrantLock();
private final Condition condition = lock.newCondition();
try
{
log.info("{} - Subscribing to topic {}", id, topic);
- pollIntervalAwareRebalanceListener.enableCommits();
- consumer.subscribe(Arrays.asList(topic), pollIntervalAwareRebalanceListener);
+ consumer.subscribe(Arrays.asList(topic), rebalanceListener);
while (true)
{
record.value()
);
- handler.accept(record);
+ recordHandler.accept(record);
consumed++;
}
- pollIntervalAwareRebalanceListener.beforeNextPoll();
+ rebalanceListener.beforeNextPoll();
}
}
catch(WakeupException e)
{
log.info("{} - RIIING! Request to stop consumption - commiting current offsets!", id);
+ consumer.commitSync();
shutdown();
}
catch(RecordDeserializationException e)
offset,
e.getCause().toString());
+ consumer.commitSync();
shutdown(e);
}
catch(Exception e)
{
- log.error("{} - Unexpected error: {}, disabling commits", id, e.toString(), e);
- pollIntervalAwareRebalanceListener.disableCommits();
+ log.error("{} - Unexpected error: {}", id, e.toString(), e);
shutdown(e);
}
finally