From 135e90f00ff7dc4dee5cab8f8f18e88e89a8af43 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Sun, 10 Nov 2024 15:50:07 +0100 Subject: [PATCH] =?utf8?q?Vorlage=20f=C3=BCr=20die=20=C3=9Cbung=20zu=20fac?= =?utf8?q?hlichen=20Fehlern?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- README.sh | 39 ------------------- .../java/de/juplo/kafka/ExampleConsumer.java | 24 +++--------- 2 files changed, 6 insertions(+), 57 deletions(-) delete mode 100755 README.sh diff --git a/README.sh b/README.sh deleted file mode 100755 index b46e235..0000000 --- a/README.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash - -IMAGE=juplo/spring-consumer:1.1-SNAPSHOT - -if [ "$1" = "cleanup" ] -then - docker compose -f docker/docker-compose.yml down -t0 -v --remove-orphans - mvn clean - exit -fi - -docker compose -f docker/docker-compose.yml up -d --remove-orphans kafka-1 kafka-2 kafka-3 -docker compose -f docker/docker-compose.yml rm -svf consumer - -if [[ - $(docker image ls -q $IMAGE) == "" || - "$1" = "build" -]] -then - mvn clean install || exit -else - echo "Using image existing images:" - docker image ls $IMAGE -fi - -docker compose -f docker/docker-compose.yml up --remove-orphans setup || exit 1 - - -docker compose -f docker/docker-compose.yml up -d producer -docker compose -f docker/docker-compose.yml up -d consumer - -sleep 5 -docker compose -f docker/docker-compose.yml stop consumer - -docker compose -f docker/docker-compose.yml start consumer -sleep 5 - -docker compose -f docker/docker-compose.yml stop producer consumer -docker compose -f docker/docker-compose.yml logs consumer diff --git a/src/main/java/de/juplo/kafka/ExampleConsumer.java b/src/main/java/de/juplo/kafka/ExampleConsumer.java index 9a1984f..001d5a6 100644 --- a/src/main/java/de/juplo/kafka/ExampleConsumer.java +++ b/src/main/java/de/juplo/kafka/ExampleConsumer.java @@ -57,24 +57,12 @@ public class ExampleConsumer implements Runnable log.info("{} - Received {} messages", id, records.count()); for (ConsumerRecord record : records) { - try - { - handleRecord( - record.topic(), - record.partition(), - record.offset(), - record.key(), - record.value()); - } - catch (NumberFormatException e) - { - log.error( - "{} - Ignoring invalid message for offset {} on partition {}: {}", - id, - record.offset(), - record.partition(), - record.value()); - } + handleRecord( + record.topic(), + record.partition(), + record.offset(), + record.key(), + record.value()); } } } -- 2.20.1