Skip to content

icemachined/kafka-kotlin-native

Repository files navigation

Kafka-Kotlin-Native

Releases Maven Central License Build and test Lines of code Hits-of-Code GitHub repo size Run deteKT Run diKTat

Fully Native Apache Kafka client for Kotlin Native. Uses native c-interop with highly performant and reliable librdkafka C client library. This library contains no JVM dependencies, no jvm runtime required. It uses Kotlin Native memory model and Multithreaded coroutines for non-blocking interaction with native callbacks and asynchronous workers.

Contribution

We will be glad if you will test kafka-kotlin-native or contribute to this project. In case you don't have much time for this - at least spend 5 seconds to give us a star to attract other contributors!

Thanks! 🙏 🥳

Acknowledgement

Special thanks to those awesome developers who give us great suggestions, help us to maintain and improve this project: @olonho, @akuleshov7.

Supported platforms

The code has both common and native parts. It can be built for each platform for which librdkafka has support. Currently, this is Linux, Windows and Mac OSX.

For more information about platforms and how to install librdkafka see librdkafka installation

Dependency

The library is hosted on the Maven Central. To import kafka-kotlin-native library you need to add following dependency to your code:

Maven
<dependency>
  <groupId>com.icemachined</groupId>
  <artifactId>kafka-client</artifactId>
  <version>0.2.0</version>
</dependency>
Gradle Groovy
implementation 'com.icemachined:kafka-client:0.2.0'
Gradle Kotlin
implementation("com.icemachined:kafka-client:0.2.0")

Features

  • Synchronous and asynchronous send
  • Leverages kotlin-native coroutines and memory model
  • Polling Kafka consumer
  • Parallel polling Kafka consumer
  • Headers enrichment
  • Error handling extension points
  • Possibility to leverage kotlinx.serialization features

How to use

See example of usage in example project This example shows how to start/stop producer and consumer and how to configure it.

Configuration

  • librdkafka configuration properties, which you can pass to producer and consumer constructor.
  • Serializer/Deserializer for key and value.