Kafka Channel Adapter
The kafka-channel-adapter module provides integration with Apache Kafka 3.6.x.
Dependency
<dependency>
<groupId>io.pipelite</groupId>
<artifactId>kafka-channel-adapter</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
Usage as source (consumer)
Pipelite.defineFlow("kafka-consumer")
.fromSource("kafka://my-topic")
.process("handle", exchange -> {
String record = exchange.getInputPayloadAs(String.class);
// process the Kafka record
})
.toSink("slf4j://log")
.build();
The KafkaPollingConsumer polls on a dedicated thread via KafkaConsumerService.
Usage as sink (producer)
.toSink("kafka://output-topic")
The DefaultKafkaProducer sends the serialized payload as the Kafka record value.
Configuration
Kafka configuration is provided via KafkaChannelConfigurer:
KafkaChannelConfigurer configurer = (config) -> {
config.setBootstrapServers("localhost:9092");
config.setGroupId("pipelite-consumer-group");
config.setAutoOffsetReset("earliest");
};
With Spring Boot, the configurer can be defined as a @Bean.