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 send(String message) throws InterruptedException { int count = 0; while (count < 3) { try { sqs.sendMessage(queueUrl, message); break; } catch (AmazonServiceException ex) { count++; if (ex.getErrorCode().equals("RequestError") && ex.getStatusCode() == 400) { System.out.println("SQS message payload size too large, will retry with a smaller message size"); sqs.sendMessage(queueUrl, message.substring(0, Math.min(message.length(), 256))); } } Thread.sleep(Math.min((int) Math.pow(2, count) * 1000, 10000)); } }

Questions about programming?Chat with your personal AI assistant