A simple SQS consumer with backoff strategy for failure processing.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.gitignore
LICENSE
README.md
build.gradle

README.md

SQS Consumer

A simple SQS consumer with backoff strategy for failure processing.

Example Usage

int numListenerThreads = 5;
ExecutorService executorService = Executors.newFixedThreadPool(numListenerThreads);
AmazonSQS sqs = AmazonSQSClientBuilder.defaultClient();

for (int i = 0; i < numListenerThreads; ++i) {
    executorService.submit(SQSConsumer.builder()
        .withMaxNumberOfMessages(10)
        .withSqs(sqs)
        .withMessageProcessor(m -> System.out.println("received message: " + m))
        .withBackOff(new SQSMessageWaitTimeFunction(
            new ExponentialBackoffStrategy(),
            Duration.ofMinutes(1), // initial wait time
            Duration.ofHours(1) // maximum wait time for a message across all retries
        ))
        .withQueueURL(sqs.getQueueUrl("TestQueue").getQueueUrl())
        .build()
    );
}