Skip to content

Small library to helps handling retries when writting kafka connect plugins

License

Notifications You must be signed in to change notification settings

Willena/connect-retryable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Maven Central

Connect Retryable

A simple library to handle multiple retries in case of Exceptions in Kafka Connectors (Sink)

It provides:

  • Retry Count
  • Retry with backoff
    • Constant
    • Exponential
    • No backoff
  • Retry timeout

Simple Example

import io.github.willena.connect.backoff.BackoffTimers;
import io.github.willena.connect.retry.Condition;
import io.github.willena.connect.retry.Retryable;

import java.time.Duration;
import java.time.temporal.ChronoUnit;

public class MyApp {

    public MyApp() {

        Retryable r = Retryable.builder()
                .withMaxRetries(10)
                .withBackoffTimer(BackoffTimers.noBackoff())
                .withMaxRetryTimeout(Duration.of(1, ChronoUnit.DAYS))
                .when(Condition.isInstance(Exception.class)).build();

        // call can throws RetryCountExceeded, BackoffInterruptedException, RetryTimeoutExceeded
        // if function does not succeed in time...
        r.call("Call my database", () -> {
            // Do something that can return an exception
            Integer.parseInt("Not and int ");
        });

    }

}

About

Small library to helps handling retries when writting kafka connect plugins

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages