Using the  v0.9.0.1 consumer API, I recently learned that paused partitions can 
unexpectedly become become unpaused during a rebalance. I also found an old 
thread from the mailing list which corroborates this behavior:


http://grokbase.com/t/kafka/users/161wgzckze/new-consumer-pause-reset-behaviour


<http://grokbase.com/t/kafka/users/161wgzckze/new-consumer-pause-reset-behaviour>While
 I can maintain the partition state myself, it seems like it would be a lot 
easier if this were either handled internally by the consumer API (i.e. pause 
the partitions that were previously paused before resuming) and/or make the 
partition state available to the RebalanceListener.


I did not find any existing tickets in JIRA related to this so I am wondering 
if this is a valid bug/enhancement or if someone found a decent workaround. All 
of the consumer API examples that I have found do not appear to handle this 
scenario.


Here is the code snippet from he client I have been working on:


consumer.pause(consumer.assignment().toArray(EMPTYTPARRAY));

while (!isWritable()) {
  // WARNING: if there is a rebalance, this call may return some records!!!
  consumer.poll(0);
  Uninterruptibles.sleepUninterruptibly(pauseWait, TimeUnit.MILLISECONDS);
}

consumer.resume(consumer.assignment().toArray(EMPTYTPARRAY));


Thanks,

Paul



Reply via email to