Code Monkey home page Code Monkey logo

curtis-kafka's Introduction

Curtis-Kafka

Custom Kafka Producer and Consumer apps.

Article: https://www.javaworld.com/article/3060078/big-data/big-data-messaging-with-kafka-part-1.html

Source: https://github.com/denisecase/kafka-api

Goal:

  • Create your own CustomConsumer.
  • Create your own CustomProducer to auto-generate and send at least 10 messages to a topic using the Twitter API.
  • Use a custom namespace to avoid naming conflicts with other "CustomProducer" classes.

Alternate:

  • Use Facebook API, or create a random word generator, choose a random noun-verb-noun, or cycle through a list sending one message every second.
  • Experiment - the goal is to be comfortable adding external messaging to any Java app.

Recommended Environment

Prerequisities

  • Twitter Developer Account
  • OpenJDK or JDK (8 or up)
  • Apache Maven
  • Apache Zookeeper
  • Apache Kafka

Also:

  • Configure system environment variables including Path.
  • Configure Zookeeper
  • Configure Kafka

Complete your Project

  • Determine your namespace.
  • Follow the Maven standard project directory structure.
  • Use src\main\java for your code (with namespace folders)
  • Use src\main\resources for your proporties files.
  • Write your custom Kafka Producer in your namespace.
  • Write your custome Kafka Consumer in your namespace.
  • Add pom.xml
  • Add README.md
  • Add .gitignore

Compile and Build a Fat Jar File

Open PowerShell as Administrator in the root project folder, compile the code using Maven and create an executable jar file. Generated artificacts can be found in the new 'target' folder.

mvn clean compile assembly:single

1 - Start Zookeeper Service

Start and keep running the Zookeeper service.

zkserver

2 - Start Kafka Service

Start and keep running the Kafka service. What directory must you be in?

 .\kafka-server-start.bat .\server.properties

3 - Start Consumer

Open PowerShell as Administrator in the root project folder, start the original consumer app:

java -cp target/kafka-case-1.0-SNAPSHOT-jar-with-dependencies.jar edu.nwmissouri.isl.professorcase.kafka.CustomConsumer

4 - Start Producer

Open a new PowerShell as Administrator in the root project folder, start the Producer app using topic test:

java -cp target/kafka-case-1.0-SNAPSHOT-jar-with-dependencies.jar edu.nwmissouri.isl.professorcase.kafka.CustomProducer

Test Communications

Verify messages are output by the Consumer.

Accessing Twitter with Code

See http://www.baeldung.com/twitter4j

For help registering your Twitter API see this Tweepy article: http://www.compjour.org/tutorials/getting-started-with-tweepy/

Register app: https://apps.twitter.com

Developer Agreement: https://developer.twitter.com/en/developer-terms/agreement-and-policy

Twitter App Attributes Example:

  • Name: KafkaCaseCustomProducer
  • Description: Sample app to illustrate working with the Twitter API and using Kafka from a Java application
  • Website: https://bitbucket.org/professorcase/h08
  • Callback URL: (blank)

Reference

See also

curtis-kafka's People

Contributors

davidbradlycurtis avatar dependabot[bot] 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.