kafka4s


License

License

GroupId

GroupId

com.banno
ArtifactId

ArtifactId

kafka4s_2.12
Last Version

Last Version

3.0.0-M25
Release Date

Release Date

Type

Type

jar
Description

Description

kafka4s
kafka4s
Project URL

Project URL

https://github.com/banno/kafka4s
Project Organization

Project Organization

Jack Henry & Associates, Inc.®
Source Code Management

Source Code Management

https://github.com/Banno/kafka4s

Download kafka4s_2.12

How to add to project

<!-- https://jarcasting.com/artifacts/com.banno/kafka4s_2.12/ -->
<dependency>
    <groupId>com.banno</groupId>
    <artifactId>kafka4s_2.12</artifactId>
    <version>3.0.0-M25</version>
</dependency>
// https://jarcasting.com/artifacts/com.banno/kafka4s_2.12/
implementation 'com.banno:kafka4s_2.12:3.0.0-M25'
// https://jarcasting.com/artifacts/com.banno/kafka4s_2.12/
implementation ("com.banno:kafka4s_2.12:3.0.0-M25")
'com.banno:kafka4s_2.12:jar:3.0.0-M25'
<dependency org="com.banno" name="kafka4s_2.12" rev="3.0.0-M25">
  <artifact name="kafka4s_2.12" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.banno', module='kafka4s_2.12', version='3.0.0-M25')
)
libraryDependencies += "com.banno" % "kafka4s_2.12" % "3.0.0-M25"
[com.banno/kafka4s_2.12 "3.0.0-M25"]

Dependencies

compile (8)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.12.13
co.fs2 : fs2-core_2.12 jar 2.5.3
org.apache.kafka : kafka-clients jar 2.7.0
io.confluent » kafka-avro-serializer jar 6.0.2
com.sksamuel.avro4s : avro4s-core_2.12 jar 3.1.0
io.prometheus : simpleclient jar 0.9.0
io.chrisdavenport : log4cats-slf4j_2.12 jar 1.1.1
org.scala-lang.modules : scala-collection-compat_2.12 jar 2.4.3

test (13)

Group / Artifact Type Version
org.apache.kafka : kafka-clients jar 2.7.0
org.apache.curator : curator-test jar 5.1.0
org.apache.kafka : kafka_2.12 jar 2.7.0
org.apache.kafka : kafka-streams jar 2.7.0
org.apache.kafka : kafka-streams-test-utils jar 2.7.0
ch.qos.logback : logback-classic jar 1.2.3
org.slf4j : log4j-over-slf4j jar 1.7.30
org.scalacheck : scalacheck_2.12 jar 1.15.3
org.scalatest : scalatest_2.12 jar 3.2.7
org.scalatestplus : scalacheck-1-15_2.12 jar 3.2.7.0
com.github.chocpanda : scalacheck-magnolia_2.12 jar 0.6.0
org.typelevel : cats-laws_2.12 jar 2.5.0
org.typelevel : discipline-scalatest_2.12 jar 2.1.3

Project Modules

There are no modules declared in this project.

kafka4s - Functional programming with Kafka and Scala

CI Maven Central Javadocs License Code of Conduct

kafka4s provides pure, referentially transparent functions for working with Kafka, and integrates with FP libraries such as cats-effect and fs2.

Head on over to the microsite

Quick Start

To use kafka4s in an existing SBT project with Scala 2.13 or a later version, add the following dependencies to your build.sbt depending on your needs:

libraryDependencies ++= Seq(
  "com.banno" %% "kafka4s" % "<version>"
)

Note: If your project uses fs2 1.x, you'll want releases from the 2.x series. For fs2 2.x projects, you'll want 3.x series releases.

Sending records to Kafka is an effect. If we wanted to periodically write random integers to a Kafka topic, we could do:

Stream
  .resource(ProducerApi.resource[F, Int, Int](BootstrapServers(kafkaBootstrapServers)))
  .flatMap { producer =>
    Stream
      .awakeDelay[F](1 second)
      .evalMap { _ =>
        Sync[F].delay(Random.nextInt()).flatMap { i =>
          producer.sendAndForget(new ProducerRecord(topic.name, i, i))
        }
      }
  }

Polling Kafka for records is also an effect, and we can obtain a stream of records from a topic. We can print the even random integers from the above topic using:

Stream.resource(
   ConsumerApi
      .resource[F, Int, Int](
        BootstrapServers(kafkaBootstrapServers),
        GroupId("example3"),
        AutoOffsetReset.earliest,
        EnableAutoCommit(true)
      )
  )
  .evalTap(_.subscribe(topic.name))
  .flatMap(
    _.recordStream(1.second)
      .map(_.value)
      .filter(_ % 2 == 0)
      .evalMap(i => Sync[F].delay(println(i)))
  )

Learning more

To learn more about kafka4s, start with our Getting Started Guide, play with some example apps, and check out the kafka4s Scaladoc for more info.

com.banno

Banno

The Banno Platform at Jack Henry and Associates

Versions

Version
3.0.0-M25
3.0.0-M24
3.0.0-M23
3.0.0-M22
3.0.0-M21
3.0.0-M17
3.0.0-M16
3.0.0-M15
3.0.0-M14
3.0.0-M13
3.0.0-M12
3.0.0-M10
3.0.0-M9
3.0.0-M7
3.0.0-M6
3.0.0-M5
3.0.0-M4
3.0.0-M3
3.0.0-M2
3.0.0-M1
2.1.0-M22
2.1.0-M21
2.1.0-M20
2.1.0-M19
2.1.0-M18
2.1.0-M17
2.1.0-M16
2.1.0-M15
2.1.0-M14
2.1.0-M8
2.1.0-M7
2.1.0-M6