Skip to content

An example of a consumer Java application that consumes events from an Apache Kafka broker

License

Notifications You must be signed in to change notification settings

lealceldeiro/kafkaconsumer

Repository files navigation

Example Java application: Apache Kafka Consumer

An example of a consumer Java application that consumes events from an Apache Kafka broker

Requirements

Build and run

Run ./mvnw compile exec:java -Dexec.mainClass="com.kafkaexamples.kafkaconsumer.KafkaConsumerMain" -Dexec.args="localhost:9094 1 topic1"

  • Check the console as messages (consumed from the broker) start to appear
  • Type /exit and press enter to stop the program (it may take a while to completely shut down gracefully -- wait patiently)

Note: replace the provided arguments with the correct values for your Kafka cluster. In the previous example:

  • localhost:9094 is the broker url
  • 1 is the number of consumers to be started
  • topic1 is the topic name to subscribe to

About

An example of a consumer Java application that consumes events from an Apache Kafka broker

Resources

License

Stars

Watchers

Forks

Languages