All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.quarkiverse.reactive.messaging.nats.jetstream.ExponentialBackoff Maven / Gradle / Ivy

There is a newer version: 3.17.0
Show newest version
package io.quarkiverse.reactive.messaging.nats.jetstream;

import java.time.Duration;

public record ExponentialBackoff(boolean enabled, Duration maxDuration) {

    public Duration getDuration(long deliveryCount) {
        long backoffSeconds = Math.round(Math.pow(2D, deliveryCount));
        return backoffSeconds < maxDuration.getSeconds() ? Duration.ofSeconds(backoffSeconds) : maxDuration;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy