Coder Social home page Coder Social logo

kstreams-failable's Introduction

CircleCI

kstreams-failable

Kafka Streams extension with failure handling methods.

How to Use

// Import FailableKStream and related exception
import org.apache.kafka.streams.kstream.FailableKStream;
import org.apache.kafka.streams.kstream.RetryableException;

// Define your topology as normal
final StreamsBuilder builder = new StreamsBuilder();
final KStream<String, String> input = builder.stream("inputTopicName");

// Decorate the topology with Retryable methods;
final FailableKStream<String, String> failableStream = FailableKStream.fromKStream(input);

// Use retryableForEach DSL method
failableStream.retryableForEach((key, value) -> {
  try {
    apiPushThatIntermittentlyFails(value);
  } catch (Exception e) {
    throw new RetryableException(e);
  }
});

Retryable Behavior

The DSL methods added by this extension handle failure in the blocks provided to them as follows:

  • If the block throws a FailableException, the method will not attempt to retry the block. A message will be published to a Dead Letter Topic representing the key and value that the block attempted to process, as well as data about the number of attempts.
  • If the block throws a RetryableException, the method will schedule another attempt to execute the block with the same key and value. This scheduled retry will be non-blocking; the node will continue to consume messages before and after any scheduled retries. Each successive retry will be scheduled with a delay approximately twice as long as the previous delay. If 10 retries are attempted that cause RetryableException to be thrown, the provided key and value will be considered not retryable, will be published to a Dead Letter Topic as if a FailableException had occurred, and will not be scheduled for a retry.

DSL Methods Added

retryableForEach

A retryable version of KStream's foreach method.

Development Setup

# Install required version of Java
asdf install

# Get Java dependencies
./gradlew dependencies

Run Unit Tests

./gradlew test

kstreams-failable's People

Contributors

wbushey avatar

Stargazers

Tyler Holien avatar

Watchers

James Cloos avatar Tyler Holien avatar Erik Braegelmann avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.