Kafka Lite

A lightweight single-node Kafka deployment for testing purposes

License

License

GroupId

GroupId

io.thill.kafkalite
ArtifactId

ArtifactId

kafka-lite
Last Version

Last Version

0.9.1
Release Date

Release Date

Type

Type

jar
Description

Description

Kafka Lite
A lightweight single-node Kafka deployment for testing purposes
Project URL

Project URL

https://github.com/thillio/kafka-lite
Source Code Management

Source Code Management

https://github.com/thillio/kafka-lite

Download kafka-lite

How to add to project

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

Dependencies

compile (4)

Group / Artifact Type Version
org.slf4j : slf4j-api jar 1.7.25
org.apache.kafka : kafka_2.12 jar 2.1.0
org.apache.curator : curator-test jar 2.12.0
junit : junit jar 4.12

test (1)

Group / Artifact Type Version
org.slf4j : slf4j-simple jar 1.7.25

Project Modules

There are no modules declared in this project.

kafka-lite

A single-node Kafka Server for Unit Testing and Running Locally

How It Works

A set of idempotent operations built around Apache Curator's Testing Server for Zookeeper and Kafka's KafkaStartableServer class.

Unit Testing

Setup

@Before
public void start() throws KafkaLiteException {
  KafkaLite.clean(); // all topics should be deleted for the start of each test
  KafkaLite.start(); // ensure kafka is up and running at the start of each test
}

Starting and Stopping

KafkaLite.start();
KafkaLite.stop();
KafkaLite.start();
KafkaLite.stop();

Topic Management

KafkaLite.createTopic("my_topic", numPartitions);
KafkaLite.createTopic("my_topic", numPartitions, retentionMillis);

Blocking

All KafkaLite methods block until the operation completes.

KafkaLite.start();
// Zookeeper and Kafka are immediately up and reachable
KafkaLite.createTopic("my_topic", 1);
// Topic is immediately available for reading/writing

Idempotence

Repeating calls to the same method should result in the same state without throwing any exceptions.

KafkaLite.start();
KafkaLite.start();
KafkaLite.clean();
KafkaLite.clean();
KafkaLite.stop();
KafkaLite.stop();

Running Locally

$ mvn exec:java -Dexec.mainClass="io.thill.kafkalite.KafkaLite" -Dexec.classpathScope="test" -Dexec.args="true"

Cleanup on shutdown

KafkaLite.cleanOnShutdown();

Versions

Version
0.9.1
0.9.0