krux / java-kafka-client-libs

The Krux Kafka Client library as a simple wrapper for the Kafka-provided client libraries, both producers and consumers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

THIS REPOSITORY IS NO LONGER MAINTAINED AND ARCHIVED.

Krux Kafka Client Library

The Krux Kafka Client library as a simple wrapper for the Kafka-provided client libraries, both producers and consumers, that's built atop the Krux Standard Library and automatically emits tons of useful usage statistics (such as messages processed rates and processing time histograms) on a per-topic basis. It also provides a pattern for configuring multiple topics to be handled by a single, thread-safe consumer, a common pattern at Krux.

Using

To use, add the following dependency to your pom.xml:

<dependency>
  <groupId>com.krux</groupId>
  <artifactId>kafka-client-libs</artifactId>
  <version>1.6.9</version>
</dependency>

Simple Use

/* Krux' Kafka consumer client handles threads, stats, status for you */

/* first, implement the MessageHandler interface */
public interface MessageHandler<T extends Object> {
    public void onMessage( T message );
}
/* Then instantiate, pass to Krux' Kafka Consumer, .start() */
final MessageHandler<Object> myHandler = new MySimpleHandler<Object>();
KafkaConsumer consumer = new KafkaConsumer( options, myHandler );

//handles message consumption in a non-daemon thread
consumer.start();

More Advanced Use

See example consumer and producer applications.

About

The Krux Kafka Client library as a simple wrapper for the Kafka-provided client libraries, both producers and consumers

License:Apache License 2.0


Languages

Language:Java 100.0%