Shreyas arya

Generation

generate functionThu, 09 Feb 2023

When requests to Step Function fail, Workflow Service performs exponential backoff retries to notify Step Function service. Number of retries = 3 The total duration of all attempts doesn't exceed 10 seconds, the processing must not exceed the message visibility timeout.

public class RetryFunction implements Function<Throwable, Integer> { private static final Logger LOG = LoggerFactory.getLogger(RetryFunction.class); private static final long BASE_SLEEP = (long) (Math.pow(2, 0) * 100); private static final long MAX_SLEEP = (long) (Math.pow(2, 3) * 100); @Override public Integer apply(Throwable throwable) { LOG.info("error", throwable); long sleepTime = BASE_SLEEP; if (throwable instanceof ActivityTaskFailedException) { ActivityTaskFailedException activityTaskFailedException = (ActivityTaskFailedException) throwable; // sleepTime = Long.parseLong(activityTaskFailedException.getCause().getMessage()); sleepTime = MAX_SLEEP; } if (sleepTime > MAX_SLEEP) { sleepTime = MAX_SLEEP; } LOG.info("sleepTime={}", sleepTime

Questions about programming?Chat with your personal AI assistant