From: Kai Moritz Date: Fri, 18 Nov 2022 15:52:21 +0000 (+0100) Subject: SimpleConsumer signalisiert Exit-Status im Rückgabewert X-Git-Tag: spring-consumer--json--adder---lvm-2-tage--easypath~3 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=39e2fe39ffbeba4fe7cae5e9d1786e51c12714d6;p=demos%2Fkafka%2Ftraining SimpleConsumer signalisiert Exit-Status im Rückgabewert --- diff --git a/src/main/java/de/juplo/kafka/SimpleConsumer.java b/src/main/java/de/juplo/kafka/SimpleConsumer.java index 3b0202f..45f9b94 100644 --- a/src/main/java/de/juplo/kafka/SimpleConsumer.java +++ b/src/main/java/de/juplo/kafka/SimpleConsumer.java @@ -9,11 +9,12 @@ import org.apache.kafka.common.errors.WakeupException; import java.time.Duration; import java.util.Arrays; +import java.util.concurrent.Callable; @Slf4j @RequiredArgsConstructor -public class SimpleConsumer implements Runnable +public class SimpleConsumer implements Callable { private final String id; private final String topic; @@ -23,7 +24,7 @@ public class SimpleConsumer implements Runnable @Override - public void run() + public Integer call() { try { @@ -50,11 +51,13 @@ public class SimpleConsumer implements Runnable catch(WakeupException e) { log.info("{} - Consumer was signaled to finish its work", id); + return 0; } catch(Exception e) { log.error("{} - Unexpected error: {}, unsubscribing!", id, e.toString()); consumer.unsubscribe(); + return 1; } finally {