Skip to content

Latest commit

 

History

History
68 lines (44 loc) · 1.52 KB

04.2-compression.md

File metadata and controls

68 lines (44 loc) · 1.52 KB

<< back to main index

Lab 4.2 : Compression

Instructor

Please demo this example, and do the lab together with students, step by step

Overview

Enable compression on Producer

Depends On

None

Run time

15 mins

Step 1 : Create testc topic

IF you haven't done before, let's create a testc topic

$   ~/apps/kafka/bin/kafka-topics.sh  --bootstrap-server localhost:9092   \
       --create --topic testc --replication-factor 1  --partitions 2

Step 2 : Run a console consumer

In a terminal

$  ~/apps/kafka/bin/kafka-console-consumer.sh \
        --bootstrap-server localhost:9092 \
        --property print.key=true --property key.separator=":" \
        --topic testc

or if you have Kafkacat

$   kafkacat -q -C -b localhost:9092 -t testc -f 'Partition %t[%p], offset: %o, key: %k, value: %s\n'

Step 3 : Compression Producer

  • Inspect file : src/main/java/x/lab04_benchmark/CompressionProducer.java.
  • Fix TODO items
  • Run the Producer In Eclipse,
    • Right click on 'src/main/java/x/lab04_benchmark/CompressionProducer.java'
    • Run as 'Java Application'

In Eclipse console, you should see output as follows:

sending : ProducerRecord(topic=test, partition=null, key=1, value=Hello world, timestamp=null)

Step 4 : Monitor Kafka console consumer

The messages should show up in Kafka console terminal !
Yay !!

We can see transparent compression from Producer --> Consumer