Date Tags Kafka / Java

Version 2.4.0 of Kafka for JUnit has been released. It increases all Kafka dependencies to 2.4.0 as well as the Testcontainers for Kafka dependency to 1.12.4.

Migration path

Unfortunately, the upgrade of the Kafka dependencies to their latest version introduced breaking changes into Kafka for JUnit. The default TopicManager implementation that comes with this library had to be re-written entirely, as the former ZkUtils-based approach is no longer working for Kafka 2.4.0.

  • The at method of ExternalKafkaCluster no longer requires a ZooKeeper connection URL. This means that instead of using ExternalKafkaCluster.at(bootstrapServers, zkConnectString), you have to use ExternalKafkaCluster.at(bootstrapServers) from now on.
  • To shield us from Kafka API changes, we copied the essential parts of the kafka.api.LeaderAndIsr class to net.mguenther.kafka.junit.LeaderAndIsr. The latter is a simple transfer object which closes only over the node IDs of the leader and the In-Sync-Replica set. This means:
  • Change package imports from kafka.api.LeaderAndIsr to net.mguenther.kafka.junit.LeaderAndIsr.
  • If you rely on LeaderAndIsr#leader in your test cases you should change that call to LeaderAndIsr#getLeader. This is not necessary straight away, but the method LeaderAndIsr#leader will be removed with a future release.

Changelog

See the changelog on GitHub.

Features

Bugfixes

None.

Get it

You can obtain the binaries from Maven central or include the dependency using the following Maven coordinates in your build.

Maven

<dependency>
  <groupId>net.mguenther.kafka</groupId>
  <artifactId>kafka-junit</artifactId>
  <version>2.4.0</version>
</dependency>

Gradle

compile 'net.mguenther.kafka:kafka-junit:2.4.0'

Hi there! I'm Markus!

I'm an independent freelance IT consultant, a well-known expert for Apache Kafka and Apache Solr, software architect (iSAQB certified) and trainer.

How can I support you?

GET IN TOUCH