Vorlage
[demos/kafka/training] / src / main / java / de / juplo / kafka / SimpleConsumer.java
index 45f9b94..82d6794 100644 (file)
@@ -19,6 +19,7 @@ public class SimpleConsumer implements Callable<Integer>
   private final String id;
   private final String topic;
   private final Consumer<String, Message> consumer;
+  private final MessageHandler messageHandler;
 
   private long consumed = 0;
 
@@ -55,8 +56,7 @@ public class SimpleConsumer implements Callable<Integer>
     }
     catch(Exception e)
     {
-      log.error("{} - Unexpected error: {}, unsubscribing!", id, e.toString());
-      consumer.unsubscribe();
+      log.error("{} - Unexpected error: {}!", id, e.toString());
       return 1;
     }
     finally
@@ -76,5 +76,6 @@ public class SimpleConsumer implements Callable<Integer>
   {
     consumed++;
     log.info("{} - {}: {}/{} - {}={}", id, offset, topic, partition, key, value);
+    messageHandler.handle(key, value);
   }
 }