Integrating Kafka with a Helidon MicroProfile Application - Part1

The Apache Kafka has become an industry defacto standard for  all messaging use cases that you may find today for an enterprise application.  In this short post I am sharing a simple application that show cases classic integration of Kafka APIs with a Helidon MicroProfile application. You can checkout the source form here:

What is the usecase exercised in this example ?
It is simple :) We use the a simple greeting REST API  to exercise the Kafka messaging feature. When a client updates the greeting message, the Greeting resource implementation will publish the new greeting message to Kafka topic for use by interested parties(consumers)

Who does what?
Here is quick summary of the classes that you find in the source:
  • ClassicKafkaMessageConsumer: This class contains the logic for listening to the Kafka topic. This class uses a custom annotation '@Startup' so that it gets instantiated on application start up. The annotation '@Startup' is provided by class in this project. To learn more about this extension, read section '16.1. Creating an Extension' in
  • ClassicKafkaMessageProducer: This class contains the logic for publishing messages to the Kafka topic. It is used by GreetResource class.
  • GreetResource: This is the REST resource implementation used in this example. When updateGreeting method is called via REST PUT operation, the new greeting sent by client is sent to Kafka queue for consumption by the Kafka consumers.  See the method updateGreeting() in GreetResource class to learn the usage of ClassicKafkaMessageProducer class in order to publish message to topic.
  • This config file holds the kafka configuration used in this example
How to run this example?
All instructions are available here:

What next ?
Look like it involves bit of boiler plate code to publish messages to Kafka. Well, we are not done yet :) If you are looking for declarative solution for the above usecase with less coding, check out this post: 


  1. This is really nice post, I found and love this content. I will prefer this, thanks for sharing. Web Search Api.


Post a Comment