From 26ee0dab641b0c00a99701f3afc9bfe5286ab9c3 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Sun, 20 Nov 2022 12:28:48 +0100 Subject: [PATCH] Version des `srping-consumer` mit `ErrorHandlingDeserializer` MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * Wie von den Logs nahegelegt, den `ErrorHandlingDeserializer` konfiguriert. * Das `REAME.sh` führt das korrigierte Verhalten bei einer Poison Pill vor: Der Consumer überspringt jetzt eine Poison Pill unmittelbar, wenn sie auftritt. --- README.sh | 13 +++---------- src/main/resources/application.yml | 3 ++- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/README.sh b/README.sh index 14685bb..1dcc2cd 100755 --- a/README.sh +++ b/README.sh @@ -35,21 +35,14 @@ echo 6 | http -v :8080/peter echo 77 | http -v :8080/klaus # end::nachrichten[] -echo "Writing logic error..." -# tag::logicerror[] -echo 66 | http -v :8080/peter?error=1 -# end::logicerror[] - -echo 66 | http -v :8080/peter -echo 7 | http -v :8080/klaus - -sleep 5 - echo "Writing poison pill..." # tag::poisonpill[] echo 'BOOM!' | kafkacat -P -b :9092 -t test # end::poisonpill[] +echo 66 | http -v :8080/peter +echo 7 | http -v :8080/klaus + sleep 5 docker-compose stop consumer-1 consumer-2 docker-compose logs -f consumer-1 consumer-2 diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 3afdd2f..17e94ad 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -30,10 +30,11 @@ spring: auto-offset-reset: earliest auto-commit-interval: 5s key-deserializer: org.apache.kafka.common.serialization.StringDeserializer - value-deserializer: org.springframework.kafka.support.serializer.JsonDeserializer + value-deserializer: org.springframework.kafka.support.serializer.ErrorHandlingDeserializer properties: partition.assignment.strategy: org.apache.kafka.clients.consumer.StickyAssignor metadata.max.age.ms: 1000 + spring.deserializer.value.delegate.class: org.springframework.kafka.support.serializer.JsonDeserializer spring.json.type.mapping: > ADD:de.juplo.kafka.MessageAddNumber, CALC:de.juplo.kafka.MessageCalculateSum -- 2.20.1