From 85929b7925a1afcddf6fd8b6e650ba4057be3e4d Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Fri, 15 Apr 2022 11:30:56 +0200 Subject: [PATCH] =?utf8?q?Springify:=20Die=20`@PreDestroy`-Methode=20wird?= =?utf8?q?=20nicht=20ben=C3=B6tigt?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * Spring Kafka prüft schon zuvor selbst, ob der Container noch läuft und fährt ihn ggf. herunter. --- .../java/de/juplo/kafka/EndlessConsumer.java | 23 ------------------- 1 file changed, 23 deletions(-) diff --git a/src/main/java/de/juplo/kafka/EndlessConsumer.java b/src/main/java/de/juplo/kafka/EndlessConsumer.java index a5a5ce6..5e76865 100644 --- a/src/main/java/de/juplo/kafka/EndlessConsumer.java +++ b/src/main/java/de/juplo/kafka/EndlessConsumer.java @@ -9,7 +9,6 @@ import org.springframework.kafka.annotation.KafkaListener; import org.springframework.kafka.config.KafkaListenerEndpointRegistry; import org.springframework.stereotype.Component; -import javax.annotation.PreDestroy; import java.util.List; import java.util.function.Consumer; @@ -75,26 +74,4 @@ public class EndlessConsumer registry.getListenerContainer(id).stop(); log.info("{} - Stopped - consumed {} messages so far", id, consumed); } - - @PreDestroy - public void destroy() - { - log.info("{} - Destroy!", id); - try - { - stop(); - } - catch (IllegalStateException e) - { - log.info("{} - Was already stopped", id); - } - catch (Exception e) - { - log.error("{} - Unexpected exception while trying to stop the consumer", id, e); - } - finally - { - log.info("{}: Consumed {} messages in total, exiting!", id, consumed); - } - } } -- 2.20.1