Skip to content
Branch: master
Find file History
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
.mvn/wrapper
src/main Merge pull request #222 from cescoffier/features/amqp-quickstart Jun 19, 2019
README.md Cleanup pom.xml file Mar 6, 2019
docker-compose.yaml Use the Strimzi docker images in the docker-compose descriptor in the… May 5, 2019
mvnw Add Maven wrapper to all quickstarts Mar 15, 2019
mvnw.cmd Add Maven wrapper to all quickstarts Mar 15, 2019
pom.xml

README.md

Quarkus Kafka Quickstart

This project illustrates how you can interact with Apache Kafka using MicroProfile Reactive Messaging.

Kafka cluster

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

The application can be started using:

mvn compile quarkus:dev

Then, open your browser to http://localhost:8080/prices.html, and you should see a fluctuating price.

Anatomy

In addition to the prices.html page, the application is composed by 3 components:

  • PriceGenerator - a bean generating random price. They are sent to a Kafka topic
  • PriceConverter - on the consuming side, the PriceConverter receives the Kafka message and convert the price. The result is sent to an in-memory stream of data
  • PriceResource - the PriceResource retrieves the in-memory stream of data in which the converted prices are sent and send these prices to the browser using Server-Sent Events.

The interaction with Kafka is managed by MicroProfile Reactive Messaging. The configuration is located in the application configuration.

Running in native

You can compile the application into a native binary using:

mvn clean package -Pnative

and run with:

./target/kafka-quickstart-1.0-SNAPSHOT-runner

You can’t perform that action at this time.