rapids-kafka-client

null

License

License

Categories

Categories

CLI User Interface
GroupId

GroupId

com.mageddo.rapids-kafka-client
ArtifactId

ArtifactId

rapids-kafka-client
Last Version

Last Version

2.0.6
Release Date

Release Date

Type

Type

jar
Description

Description

rapids-kafka-client
null
Project URL

Project URL

https://github.com/mageddo-projects/rapids-kafka-client
Source Code Management

Source Code Management

https://github.com/mageddo-projects/kafka-client

Download rapids-kafka-client

How to add to project

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

Dependencies

compile (2)

Group / Artifact Type Version
net.jodah : failsafe jar 2.3.5
org.apache.kafka : kafka-clients jar 2.5.0

test (2)

Group / Artifact Type Version
org.junit.jupiter : junit-jupiter jar 5.6.2
org.mockito : mockito-junit-jupiter jar 3.3.3

Project Modules

There are no modules declared in this project.

Rapids Kafka Client

Kafka Client is a vanilla java library that makes it easy to consume data from kafka, a list of features:

  • Parallel consuming
  • Consuming retry
  • Consuming failover
  • Designed to be easy to mock and test
  • Designed to support slow consumers without kafka re balancing
  • Designed to high throughput usage
  • Individual record consuming
  • Batch records consuming
  • Frameworkless, but easily configurable to some when wanted
  • Commits managed for you based on behavior
  • Low CPU usage

Getting Started

compile("com.mageddo.rapids-kafka-client:rapids-kafka-client:2.0.6")
ConsumerConfig.<String, String>builder()
.prop(KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName())
.prop(VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName())
.prop(GROUP_ID_CONFIG, "stocks")
.topics("stock_changed")
.recoverCallback(ctx -> {
  // here you can send the message to another topic, send a SMS, etc.
  log.info("status=recovering, value={}", ctx.record().value());
})
.callback((ctx, record) -> {
  log.info("status=consumed, value={}", record.value());
})
.build()
.consume()
.waitFor();

Making it easy to configure many consumers

public static void main(String[] args) {
  final ConsumerStarter consumerStarter = ConsumerStarter.start(defaultConfig(), Arrays.asList(
      new StockConsumer() // and many other consumers
  ));
  consumerStarter.waitFor();
  //    consumerStarter.stop();
}

static ConsumerConfig defaultConfig() {
  return ConsumerConfig.builder()
    .prop(CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092")
    .prop(KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName())
    .prop(VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName())
    .prop(GROUP_ID_CONFIG, "my-group-id")
    .build();
}

static class StockConsumer implements Consumer {

  ConsumeCallback<String, String> consume() {
    return (callbackContext, record) -> {
      System.out.printf("message from kafka: %s\n", record.value());
    };
  }

  @Override
  public ConsumerConfig<String, String> config() {
    return ConsumerConfig
      .<String, String>builder()
      .topics("stocks_events")
      .consumers(1)
      .callback(this.consume())
      .build();
  }
}

Examples

com.mageddo.rapids-kafka-client

Mageddo

Versions

Version
2.0.6
2.0.3
2.0.2
2.0.1
2.0.0
1.0.3
1.0.2