TheGameKafka- A Spring boot kafka client to support multi (broker, topic, consumer and producer) using spring configuration.
TheGameKafka uses a number of projects to work properly:
- Spring Boot - Open source Java-based framework
- Maven Maven is a powerful project management tool that is based on POM (project object model)
- Apache Kafka - Apache Kafka is an open-source distributed event streaming platform used by thousands of companies for high-performance data pipelines, streaming analytics, data integration, and mission-critical applications.
The following items should be installed in your system:
- Java 18 or newer.
- git command line tool (https://help.github.com/articles/set-up-git)
- Your preferred IDE
TheGameKafkaProducer<String, String> theGameKafkaProducer = theGameKafkaProducerFactory.getTheGameKafkaProducer(
"testClient");
theGameKafkaProducer.send("this is a test msg from TheGameKafkaProducer");
TheGameKafkaConsumer<String, String> theGameKafkaConsumer = theGameKafkaConsumerFactory.getTheGameKafkaConsumer(
"testClient");
theGameKafkaConsumer.listen(messageListener());
private MessageListener<String, String> messageListener() {
return rec -> log.info("TheGameKafkaConsumer listened : {}", rec);
}
the-game-kafka:
clientConsumerProperties:
- clientName: "testClient"
topic: "testTopic"
enabled: true
kafkaProperties:
consumer:
bootstrapServers: localhost:9094
groupId: "tgk-group"
autoOffset: earliest
keyDeserializer: org.apache.kafka.common.serialization.StringDeserializer
value-deserializer: org.springframework.kafka.support.serializer.ErrorHandlingDeserializer
properties:
spring:
json:
trusted:
packages: "*"
deserializer:
value:
delegate:
class: org.apache.kafka.common.serialization.StringDeserializer
clientProducerProperties:
- clientName: "testClient"
topic: "testTopic"
enabled: true
kafkaProperties:
producer:
bootstrapServers: localhost:9094
./mvnw spring-boot:run
./mvnw clean install