verteiler

verteiler is a simple multi threaded blocking queue kafka consumer api

License

License

Categories

Categories

Data
GroupId

GroupId

io.datanerds
ArtifactId

ArtifactId

verteiler
Last Version

Last Version

0.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

verteiler
verteiler is a simple multi threaded blocking queue kafka consumer api
Project URL

Project URL

http://datanerds.io
Source Code Management

Source Code Management

https://github.com/datanerds-io/verteiler

Download verteiler

How to add to project

<!-- https://jarcasting.com/artifacts/io.datanerds/verteiler/ -->
<dependency>
    <groupId>io.datanerds</groupId>
    <artifactId>verteiler</artifactId>
    <version>0.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/io.datanerds/verteiler/
implementation 'io.datanerds:verteiler:0.1.0'
// https://jarcasting.com/artifacts/io.datanerds/verteiler/
implementation ("io.datanerds:verteiler:0.1.0")
'io.datanerds:verteiler:jar:0.1.0'
<dependency org="io.datanerds" name="verteiler" rev="0.1.0">
  <artifact name="verteiler" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.datanerds', module='verteiler', version='0.1.0')
)
libraryDependencies += "io.datanerds" % "verteiler" % "0.1.0"
[io.datanerds/verteiler "0.1.0"]

Dependencies

compile (3)

Group / Artifact Type Version
org.slf4j : slf4j-api jar 1.7.21
org.apache.kafka : kafka-clients jar 0.10.2.1
com.google.guava : guava jar 18.0

test (6)

Group / Artifact Type Version
org.hamcrest : hamcrest-all jar 1.3
org.mockito : mockito-all jar 1.10.19
org.slf4j : slf4j-simple jar 1.7.21
org.awaitility : awaitility jar 2.0.0
com.google.guava : guava-testlib jar 18.0
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

Build Status

Maven Central

Verteiler (fɛɐˈtailɐ)

"Verteiler" is german and translates to distributor. When you are using the (new) kafka-clients consumer introduced with v0.9.0, you will face the issue that Consumer.poll(...) can only be called from one thread. Verteiler leverages the kafka-client consumer implementation to distribute messages from assigned partitions to BlockingQueues. Each assigned partition will relay its messages to its own internal queue. These queues have worker threads which process the message leveraging a user defined consumer. Once a message has been processed successfully its offset will be committed asynchronously after poll(...) has finished. This way only the offset of processed messages is committed.

How to use verteiler

BlockingQueueConsumer

Parameters

String topic: Name of the topic you want to consume messages from.

Properties kafkaConfig: Regular consumer config. By default verteiler will disable auto offset commit and set a client id when not given.

int queueSize: Size of the internal queue, which depends on your needs.

java.util.function.Consumer<V> action: The function which will handle a message.

Example

Simple message counter:

Properties props = new Properties();
props.setProperty(BOOTSTRAP_SERVERS_CONFIG, "127.0.0.1:9092");
...
AtomicInteger messageCounter = new AtomicInteger();
Consumer<String> action = (message) -> messageCounter.incrementAndGet();

BlockingQueueConsumer<String, String> consumer = new BlockingQueueConsumer<>("my_topic", props, 42, action);
consumer.start();

For a full example take a look at BlockingQueueConsumerTest.

Build

gradle build will build the project. The integration tests will start embedded zookeeper & kafka instances.

io.datanerds

Versions

Version
0.1.0