Git Product home page Git Product logo

kafka-producer-consumer-group-message-passing's Introduction

GitHub GitHub top language GitHub last commit





Description

Java code for creating custom Producer and Consumer group demonstrating message passing in Kafka.

Environment

  • Java JDK 8 (1.8)
  • Zookeeper
  • Kafka >= 2.0
  • Linux/Windows
  • Maven

Prerequisites

Ensure that Zookeeper & Kafka servers are up and running ( Open in separate terminal windows if necessary ).

Command to start Zookeeper

zookeeper-server-start.sh config/zookeeper.properties

Command to start Kafka server

kafka-server-start.sh config/server.properties

Installation steps

After cloning this repo,

  1. Run the maven clean install command
mvn clean install

Maven will now generate a target directory with the jar kafka-1.0-shaded.jar

  1. Move into the target directory
cd target

Execution steps

To execute the Producer class

  1. Run the kafka console consumer in another terminal window with the following topic and group parameters
kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic firstTopic --group my-third-application
  1. Execute the ProducerDemo class from the shaded jar
java -cp kafka-1.0-shaded.jar com.github.thomas.kafka.ProducerDemo
  1. You should now be able to see the output in your Kafka console consumer terminal.

To execute the Consumer class

  1. Execute the ConsumerDemo class from the shaded jar
java -cp kafka-1.0-shaded.jar com.github.thomas.kafka.ConsumerDemo
  1. Run the kafka console producer in another terminal window with the topic parameter.
kafka-console-producer.sh --broker-list localhost:9092 --topic firstTopic
  1. You should now be able to see the output in your Kafka consumer terminal. ( Step 1 )

To execute both the Producer and Consumer

  1. Execute the ProducerDemo class from the shaded jar
java -cp kafka-1.0-shaded.jar com.github.thomas.kafka.ProducerDemo
  1. Execute the ConsumerDemo class from the shaded jar
java -cp kafka-1.0-shaded.jar com.github.thomas.kafka.ConsumerDemo
  1. You should now the see the output in your Consumer terminal.

Source Code

Producer

ConsumerGroup

License

This repository is under Apache License 2.0 - see License for more details

Acknowledgement

This was inspired by Stephane Maarek. Check out his Apache Kafka Series course

kafka-producer-consumer-group-message-passing's People

Contributors

dependabot[bot] avatar thomas-george-t avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.