splitter: 1.0.0-spring-integration-xml - defined the `DirectChannel` in XML
[demos/kafka/wordcount] / src / main / java / de / juplo / kafka / wordcount / splitter / SplitterApplication.java
index 0a70551..fd3becd 100644 (file)
@@ -4,10 +4,10 @@ import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.context.properties.EnableConfigurationProperties;
 import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ImportResource;
 import org.springframework.expression.common.LiteralExpression;
 import org.springframework.integration.annotation.InboundChannelAdapter;
 import org.springframework.integration.annotation.ServiceActivator;
-import org.springframework.integration.channel.DirectChannel;
 import org.springframework.integration.config.EnableIntegration;
 import org.springframework.integration.kafka.inbound.KafkaMessageSource;
 import org.springframework.integration.kafka.outbound.KafkaProducerMessageHandler;
@@ -26,13 +26,13 @@ import org.springframework.messaging.support.ChannelInterceptor;
 @SpringBootApplication
 @EnableConfigurationProperties(SplitterApplicationProperties.class)
 @EnableIntegration
+@ImportResource("classpath:integration.xml")
 public class SplitterApplication
 {
        @Bean
-       MessageChannel words()
+       ChannelInterceptor keyInterceptor ()
        {
-               DirectChannel words = new DirectChannel();
-               words.addInterceptor(new ChannelInterceptor()
+               return new ChannelInterceptor()
                {
                        @Override
                        public Message<?> preSend(Message<?> message, MessageChannel channel)
@@ -45,8 +45,7 @@ public class SplitterApplication
                                                                .setHeader(KafkaHeaders.MESSAGE_KEY, key)
                                                                .build();
                        }
-               });
-               return words;
+               };
        }
 
        @InboundChannelAdapter(channel = "recordings")