Overview

The Apache Pekko Kafka Connector project is an open source initiative to implement stream-aware and reactive integration pipelines for Java and Scala. It is built on top of Pekko Streams, and has been designed from the ground up to understand streaming natively and provide a DSL for reactive and stream-oriented programming, with built-in support for backpressure. Apache Pekko Streams is a Reactive Streams and JDK 9+ java.util.concurrent.Flow-compliant implementation and therefore fully interoperable with other implementations.

This Apache Pekko Connectors Kafka connector lets you connect Apache Kafka to Apache Pekko Streams. It was formerly known as Apache Pekko Streams Kafka and even Reactive Kafka.

Project Info

Project Info: Apache Pekko Connectors Kafka
Artifact
org.apache.pekko
pekko-connectors-kafka
1.1.0
JDK versions
OpenJDK 8
OpenJDK 11
Scala versions2.12.20, 2.13.15, 3.3.4
JPMS module namepekko.stream.connectors.kafka
License
Home pagehttps://pekko.apache.org/docs/pekko-connectors-kafka/current/
API documentation
Forums
Release notesIn the documentation
IssuesGithub issues
Sourceshttps://github.com/apache/pekko-connectors-kafka

Matching Kafka Versions

Kafka client Scala Versions Apache Pekko version Apache Pekko Connectors Kafka Connector
3.0.1 2.12, 2.13, 3 1.0.0 1.0.0
Note

As Kafka’s client protocol negotiates the version to use with the Kafka broker, you may use a Kafka client version that is different than the Kafka broker’s version.

These clients can communicate with brokers that are version 2.1.0 or newer. Older or newer brokers may not support certain features. You will receive an UnsupportedVersionException when invoking an API that is not available on the running broker version.

Check even Confluent’s Versions and Interoperability page for more details.

Javadoc for KafkaConsumer

Dependencies

Maven
<properties>
  <pekko.version>1.1.1</pekko.version>
  <scala.binary.version>2.13</scala.binary.version>
</properties>
<dependencies>
  <dependency>
    <groupId>org.apache.pekko</groupId>
    <artifactId>pekko-connectors-kafka_${scala.binary.version}</artifactId>
    <version>1.1.0</version>
  </dependency>
  <dependency>
    <groupId>org.apache.pekko</groupId>
    <artifactId>pekko-stream_${scala.binary.version}</artifactId>
    <version>${pekko.version}</version>
  </dependency>
</dependencies>
sbt
val PekkoVersion = "1.1.1"
libraryDependencies ++= Seq(
  "org.apache.pekko" %% "pekko-connectors-kafka" % "1.1.0",
  "org.apache.pekko" %% "pekko-stream" % PekkoVersion
)
Gradle
def versions = [
  PekkoVersion: "1.1.1",
  ScalaBinary: "2.13"
]
dependencies {
  implementation "org.apache.pekko:pekko-connectors-kafka_${versions.ScalaBinary}:1.1.0"
  implementation "org.apache.pekko:pekko-stream_${versions.ScalaBinary}:${versions.PekkoVersion}"
}

This connector depends on Apache Pekko 1.0.x and note that it is important that all pekko-* dependencies are in the same version, so it is recommended to depend on them explicitly to avoid problems with transient dependencies causing an unlucky mix of versions.

Apache Pekko Connectors Kafka APIs accept a typed ActorSystemActorSystem or a classic ActorSystemActorSystem because both implement the ClassicActorSystemProviderClassicActorSystemProvider traitinterface. There are some Apache Pekko Connectors Kafka APIs that only accept classic a ActorRefActorRef, such as the rebalance listener API, but otherwise there is no difference between running Apache Pekko Connectors Kafka and any other Apache Pekko Streams implementation with a typed ActorSystemActorSystem. For more information on Apache Pekko classic and typed interoperability read the Coexistence page of the Apache Pekko Documentation.

The table below shows Apache Pekko Connectors Kafka’s direct dependencies and the second tab shows all libraries it depends on transitively.

Scala and Java APIs

Following Apache Pekko’s conventions, there are two separate packages named org.apache.pekko.kafka.scaladsl and org.apache.pekko.kafka.javadsl with the API for Scala and Java. These packages contain Producer and Consumer classes with factory methods for the various Apache Pekko Streams Flow, Sink and Source that are producing or consuming messages to/from Kafka.

Examples

A few self-contained examples using Apache Pekko Connectors are available as Apache Pekko Connectors Samples.

To read and see how others use Apache Pekko Connectors, see the Apache Pekko Connectors documentation’s Webinars, Presentations and Articles listing.

Contributing

Please feel free to contribute to Apache Pekko Connectors and the Apache Pekko Connectors Kafka connector by reporting issues you identify, or by suggesting changes to the code. Please refer to our contributing instructions to learn how it can be done.

We want Apache Pekko and Apache Pekko Connectors to strive in a welcoming and open atmosphere and expect all contributors to respect our code of conduct.