Skip to content

Kafka Katas, a collection of simple playbooks for Consumers and Producers.

License

Notifications You must be signed in to change notification settings

purbon/kafka-katas

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The Kafka katas, a collection of simple kafka client playbooks

This repository contains simple playbooks for common usages of the Java Apache Kafka client library. Here you will find help for the common question of how to do X or Y with the kafka clients.

Consumers

Offset commit

One of the most common challenges implementing a consumer is when to commit the processed offsets. This could be archived basically in three main ways, via a timer, async and sync.

Within the last two options, users can commit all incoming data, including the ones that have not changes, or commit only the latest changes.

In this code base, the reader can find:

  • SyncConsumer: An example of a sync consumer. Once the consumer call commitSync(), in this way of functioning, the consumer coordinator will commit a message for all partitions and topics where the consumer is subscribed. Because the call is sync the code will block until all offsets are commited.
  • SyncConsumerWithParams: In this version of the consumers, the application will call commitSync(offsets). This method will allow the client to pass exact offsets to commit. This option is more efficient as only commits what user is under control.
  • ASyncConsumer: This consumer will call commitAsync(), allowing the message to travel in a parallel thread not blocking the current consumer thread. This version will commit as well a message for each topic and partition, even if the offset has not changed.

Testing

You can test this playbooks with the available docker setup inside the docker/ directory. To run this, you just need to invoke the ./up script and all will come up together.

For sure, docker and docker-compose is need for this.

About

Kafka Katas, a collection of simple playbooks for Consumers and Producers.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published