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 void retry() { final int maxRetries = 3; int attempts = 0; int sleepTime = 100; Exception lastException = null; do { attempts++; try { // perform request } catch (Exception e) { lastException = e; try { Thread.sleep(sleepTime); } catch (InterruptedException ie) { break; } sleepTime *= 2; } } while (attempts < maxRetries && sleepTime < 10000); if (attempts == maxRetries) { throw lastException; } }

Questions about programming?Chat with your personal AI assistant