Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.

Latest commit

 

History

History
43 lines (32 loc) · 1.64 KB

README.md

File metadata and controls

43 lines (32 loc) · 1.64 KB

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.