Featured resource
2025 Tech Upskilling Playbook
Tech Upskilling Playbook

Build future-ready tech teams and hit key business milestones with seven proven plays from industry leaders.

Check it out
  • Lab
    • Libraries: If you want this lab, consider one of these libraries.
    • Cloud
Google Cloud Platform icon
Labs

Configuring a Kafka Client

Kafka clients such as producers and consumers can be configured much like brokers and topics. In this hands-on lab, you will have the opportunity to explore the basics of configuring Kafka clients by making some configuration changes to a simple producer written in Java. After completing this lab, you will have some experience with the process of configuring Kafka clients programmatically.

Google Cloud Platform icon
Lab platform
Lab Info
Level
Intermediate
Last updated
Sep 11, 2025
Duration
30m

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
Table of Contents
  1. Challenge

    Clone the Producer Source Code and Run it to Ensure that Everything Works
    1. Clone the producer source code into the home directory:
    cd ~/
    git clone https://github.com/linuxacademy/content-ccdak-kafka-client-config-lab.git
    
    1. Run the code to ensure it works before modifying it:
    cd content-ccdak-kafka-client-config-lab
    ./gradlew run
    
    1. To view the output, consume the records from the inventory_purchases topic:
    kafka-console-consumer --bootstrap-server localhost:9092 --topic inventory_purchases --property print.key=true --from-beginning
    
  2. Challenge

    Implement the Required Configuration Changes in the Producer and Run the Program to Test Them
    1. Edit the Main class of the producer source code:
    vi src/main/java/com/linuxacademy/ccdak/client/config/Main.java
    
    1. Add the necessary configurations to the props object before the producer is instantiated. The final code should look something like this:
    package com.linuxacademy.ccdak.client.config;
    
    import java.util.Properties;
    import org.apache.kafka.clients.producer.KafkaProducer;
    import org.apache.kafka.clients.producer.Producer;
    import org.apache.kafka.clients.producer.ProducerRecord;
    
    public class Main {
    
        public static void main(String[] args) {
            Properties props = new Properties();
            props.put("bootstrap.servers", "localhost:9092");
            props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
            props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
    
            props.put("acks", "all");
            props.put("buffer.memory", "12582912");
            props.put("connections.max.idle.ms", "300000");
    
            Producer<String, String> producer = new KafkaProducer<>(props);
            producer.send(new ProducerRecord<>("inventory_purchases", "apples", "1"));
            producer.send(new ProducerRecord<>("inventory_purchases", "apples", "3"));
            producer.send(new ProducerRecord<>("inventory_purchases", "oranges", "12"));
            producer.send(new ProducerRecord<>("inventory_purchases", "bananas", "25"));
            producer.send(new ProducerRecord<>("inventory_purchases", "pears", "15"));
            producer.send(new ProducerRecord<>("inventory_purchases", "apples", "6"));
            producer.send(new ProducerRecord<>("inventory_purchases", "pears", "7"));
            producer.send(new ProducerRecord<>("inventory_purchases", "oranges", "1"));
            producer.send(new ProducerRecord<>("inventory_purchases", "grapes", "56"));
            producer.send(new ProducerRecord<>("inventory_purchases", "oranges", "11"));
            producer.close();
        }
    
    }
    
    1. Execute the program:
    ./gradlew run
    
    1. Consume the records from the inventory_purchases topic to verify that we can see the new records created by the producer:
    kafka-console-consumer --bootstrap-server localhost:9092 --topic inventory_purchases --property print.key=true --from-beginning
    
About the author

Pluralsight Skills gives leaders confidence they have the skills needed to execute technology strategy. Technology teams can benchmark expertise across roles, speed up release cycles and build reliable, secure products. By leveraging our expert content, skill assessments and one-of-a-kind analytics, keep up with the pace of change, put the right people on the right projects and boost productivity. It's the most effective path to developing tech skills at scale.

Real skill practice before real-world application

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Learn by doing

Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.

Follow your guide

All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.

Turn time into mastery

On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.

Get started with Pluralsight