Versendete Nachrichten an den neuen Kontrakt angepasst
[demos/kafka/training] / src / main / java / de / juplo / kafka / EndlessConsumer.java
index 0f3316d..63a2f93 100644 (file)
@@ -25,7 +25,6 @@ public class EndlessConsumer<K, V> implements Runnable
   private final String id;
   private final String topic;
   private final Consumer<K, V> consumer;
-  private final ConsumerRebalanceListener rebalanceListener;
   private final RecordHandler<K, V> handler;
 
   private final Lock lock = new ReentrantLock();
@@ -42,7 +41,7 @@ public class EndlessConsumer<K, V> implements Runnable
     try
     {
       log.info("{} - Subscribing to topic {}", id, topic);
-      consumer.subscribe(Arrays.asList(topic), rebalanceListener);
+      consumer.subscribe(Arrays.asList(topic));
 
       while (true)
       {
@@ -67,13 +66,12 @@ public class EndlessConsumer<K, V> implements Runnable
 
           consumed++;
         }
-
-        handler.beforeNextPoll();
       }
     }
     catch(WakeupException e)
     {
       log.info("{} - RIIING! Request to stop consumption - commiting current offsets!", id);
+      consumer.commitSync();
       shutdown();
     }
     catch(RecordDeserializationException e)
@@ -87,6 +85,7 @@ public class EndlessConsumer<K, V> implements Runnable
           offset,
           e.getCause().toString());
 
+      consumer.commitSync();
       shutdown(e);
     }
     catch(Exception e)