Skip to content

pratah/kafka-consumer-application

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

README.md

🚨 Building a very basic consumer application that reads records from Kafka 🚨

Table of contents

  1. Project Structure
  2. Download and set up the Confluent CLI
  3. Connect to your cluster
  4. Configuring the project
  5. Unix Commands Reference table

Project Structure

Let us create our project structure by initializing a directory called kafka-consumer-application and moving into it.

Run the following command: mkdir kafka-consumer-application && cd kafka-consumer-application

Copy the cluster information and paste in a file called ccloud.properties inside the configuration folder.

By now we should have the following structure:

└── configuration
     └── ccloud.properties

Download and set up the Confluent CLI

To install Confluent CLI run the following command brew install confluentinc/tap/cli

If you don't have Homebrew already installed you can do so by going here https://brew.sh/ .

Connect to your cluster

Let us connect to our Confluent Cloud by running confluent login --save the -- save is just a flag and will save your credentials and log you back in if session expires.

We are now connected and in order to view a list of active environments run confluent environment list.

Select the environment by running confluent environment use <env-id> .

Get the cluster ID previously created at the beginning of the lab by running confluent kafka cluster list.

Select the appropriate cluster by running confluent kafka cluster use <cluster-id> .

If you created your API key using the CLI on another machine or using the UI you need to store it by runnig api-key store <api-key> <api-secret> --resource <resource-id>

If by any chance one was already stored previously we need to ooverride it by using the --force flag at the end of your command api-key store <api-key> <api-secret> --resource <resource-id> --force .

Finnaly set API key to use by running confluent api-key use <api-key> and you can now run the Confluent CLI commands against the specified cluster.

Creating a topic

If you already have a topic already created you can view it by running confluent kafka topic list .

Configuring the project

Create the following file build.gradle inside the root of your directory.

Unix Commands Reference table

Unix Command Description
mkdir This command is used to create a new directory
cd This command is used to change to a directory
touch This command is used to create an empty file

About

Basic Kafka Consumer App

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published