Skip to content

FH-Tutorials/KafkaProducerConsumer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Kafka Producer Consumer Example

Illustrates a simple example how to produce and consume messages.

Pre-Install

  • Kafka
  • maven
  • Java >=8 (best: Openjdk)
  • IDE (e.g. Eclipse, ...)

Before running the start scripts

Before executing you need to add kafka and zookeeper to your OS hosts-file. Here is a list of hosts-file locations according to your operating systems

  • Mac OS: /private/etc/hosts
  • Linux: /etc/hosts
  • Windows: C:\Windows\System32\drivers\etc\hosts

The format may vary a little but usually a new host with its hostname is defined using it's ip and the desired hostname. Thus, your host file needs to have the following entries:

127.0.0.1  kafka
127.0.0.1  zookeeper

Be aware that for some Operating Systems you might need to restart your network service or restart your computer. You may check if the entries are active by just pining with ping kafka and ping zookeeper, which should give you a response from 127.0.0.1.

Use the Applications

To build the project execute:

mvn clean install

To run a consumer:

mvn exec:java@consumer

To run the producer:

mvn exec:java@producer

Helpers

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages