This project illustrates how to use bare Apache Kafka clients and Vert.x Kafka clients in a Quarkus application.
First, you need a Kafka cluster. You can follow the instructions from the Apache Kafka web site or run docker-compose up
if you have docker installed on your machine.
Start the application in dev mode using:
mvn quarkus:dev
# post a record using the bare Kafka client
> http POST :8080/kafka key==bare value==value
# post a record using the Vert.x Kafka client
> http POST :8080/vertx-kafka key==bare value==value
# retrieve a record using the bare Kafka client
> http :8080/kafka
# retrieve a record using the Vert.x Kafka client
> http :8080/vertx-kafka
# retrieve the list of topics using the bare Kafka client
> http :8080/kafka/topics
# retrieve the list of topics using the Vert.x Kafka client
> http :8080/vertx-kafka/topics
The org.acme.kafka.KafkaProviders
and org.acme.kafka.VertxKafkaProviders
produces the Kafka consumers, produces and admin for the bare API and Vert.x API.
The org.acme.kafka.KafkaEndpoint
and org.acme.kafka.VertxKafkaEndpoint
demonstrates how these clients can be used.
Note that the configuration is retrieved using:
@Inject
@Identifier("default-kafka-broker")
Map<String, Object> config;
This config contains all the kafka.
properties from the application configuration.
You can compile the application into a native binary using:
mvn clean install -Pnative
and run with:
./target/kafka-bare-quickstart-1.0-SNAPSHOT-runner