import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
-
-import java.time.Clock;
+import org.springframework.expression.common.LiteralExpression;
+import org.springframework.integration.annotation.InboundChannelAdapter;
+import org.springframework.integration.annotation.ServiceActivator;
+import org.springframework.integration.config.EnableIntegration;
+import org.springframework.integration.kafka.inbound.KafkaMessageSource;
+import org.springframework.integration.kafka.outbound.KafkaProducerMessageHandler;
+import org.springframework.kafka.core.ConsumerFactory;
+import org.springframework.kafka.core.KafkaTemplate;
+import org.springframework.kafka.listener.ConsumerProperties;
+import org.springframework.messaging.MessageHandler;
@SpringBootApplication
@EnableConfigurationProperties(SplitterApplicationProperties.class)
+@EnableIntegration
public class SplitterApplication
{
+ @InboundChannelAdapter(channel = "recordings")
@Bean
- Clock clock()
+ KafkaMessageSource<String, String> source(
+ ConsumerFactory<String, String> cf,
+ SplitterApplicationProperties properties)
{
- return Clock.systemDefaultZone();
+ return new KafkaMessageSource<>(cf, new ConsumerProperties(properties.getInputTopic()));
}
+ @Bean
+ @ServiceActivator(inputChannel = "words")
+ MessageHandler handler(
+ KafkaTemplate<String, String> kafkaTemplate,
+ SplitterApplicationProperties properties)
+ {
+ KafkaProducerMessageHandler<String, String> handler =
+ new KafkaProducerMessageHandler<>(kafkaTemplate);
+ handler.setTopicExpression(new LiteralExpression(properties.getOutputTopic()));
+ return handler;
+ }
public static void main(String[] args)
{