From: Kai Moritz Date: Thu, 30 Jun 2022 19:34:21 +0000 (+0200) Subject: splitter: 1.0.0-spring-integration - refactored configuration X-Git-Tag: wip-integration-xml~7 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=8aaf63efd2d666aa43825ef99f81de394788fc20;p=demos%2Fkafka%2Fwordcount splitter: 1.0.0-spring-integration - refactored configuration --- diff --git a/src/main/java/de/juplo/kafka/wordcount/splitter/SplitterApplication.java b/src/main/java/de/juplo/kafka/wordcount/splitter/SplitterApplication.java index 0a70551..d9ba135 100644 --- a/src/main/java/de/juplo/kafka/wordcount/splitter/SplitterApplication.java +++ b/src/main/java/de/juplo/kafka/wordcount/splitter/SplitterApplication.java @@ -29,10 +29,17 @@ import org.springframework.messaging.support.ChannelInterceptor; public class SplitterApplication { @Bean - MessageChannel words() + MessageChannel words(ChannelInterceptor keyInterceptor) { DirectChannel words = new DirectChannel(); - words.addInterceptor(new ChannelInterceptor() + words.addInterceptor(keyInterceptor); + return words; + } + + @Bean + ChannelInterceptor keyInterceptor () + { + return new ChannelInterceptor() { @Override public Message preSend(Message message, MessageChannel channel) @@ -45,8 +52,7 @@ public class SplitterApplication .setHeader(KafkaHeaders.MESSAGE_KEY, key) .build(); } - }); - return words; + }; } @InboundChannelAdapter(channel = "recordings")