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)
.setHeader(KafkaHeaders.MESSAGE_KEY, key)
.build();
}
- });
- return words;
+ };
}
@InboundChannelAdapter(channel = "recordings")