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.
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>
/* 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();