GithubHelp home page GithubHelp logo

lab02part1-kafka-producer-consumer's Introduction

lab02Part1-kafka-producer-consumer

This lab is adapted from here.

Introduction

This lab consists of two parts. In the first part, we'll create a producer that can create messages in Kafka. In the second part, we'll consume these messages.

Both the Consumer and Producer are written in Java.

Here are the links to the labs:

  1. Producer lab
  2. Consumer lab

In this lab we'll use Java and Maven to create a typical Java based producer and consumer of Kafka messages. Apart from working on the lab in IntelliJ and let the IDE handle everything, you have two additional options for running Maven and Java. \Either, you install them natively or you can run the tools through a docker container.

Native install

If you already have Java and Maven installed, make sure you have:

  • Java 8 or higher
  • Maven 3.X

With a successful installation, you should be able to run mvn -v from command line. E.g., here is what that may look like (it may look slightly different on your machine based on the maven version and the operating system you use):

$ mvn -v
Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537)
Maven home: C:\Users\Ronny Seiger\Downloads\apache-maven-3.8.4-bin\apache-maven-3.8.4
Java version: 11.0.12, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk-11.0.12
Default locale: de_DE, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

Docker install of Maven and Java

If you decide to use docker, you would want to open a docker instance with all the tools in the root of your lab and keep it open during the lab.

For OSX and Linux, you can simply run:

$ cd DIR_WHERE_MY_LAB_IS
$ docker run -it --rm --name lab02 -v "$PWD":/usr/src/lab02 -w /usr/src/lab02 maven:3-jdk-11 bash
root@58b8ca1d738c:/usr/src/lesson#

If you are on Windows, you may have to replace the $PWD with the full path of your lab directory.

You are now running a bash shell inside your docker instance. Your directory is mapped to /usr/src/lab02 inside the docker instance.

You should be able to run the maven command to check that everything is working mvn --version. The output should be:

root@58b8ca1d738c:/usr/src/lesson30# mvn --version
Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537)
Maven home: /usr/share/maven
Java version: 11.0.14.1, vendor: Oracle Corporation, runtime: /usr/local/openjdk-1
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "5.10.60.1-microsoft-standard-wsl2", arch: "amd64", family: "unix"
root@43abc88b405f:/usr/src/lab02#

For simplicity of the lab instruction, we'll simply refer to the maven builds using the native install. However, you should be able to use the docker image above to build any of the labs. Hence, if you select to use the docker approach, when we specify

$ mvn package

We assume that you are inside your docker container when you do.

lab02part1-kafka-producer-consumer's People

Contributors

ronsei avatar

Stargazers

 avatar

Watchers

 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.