Skip to content

A simple SQS consumer with backoff strategy for failure processing.

License

Notifications You must be signed in to change notification settings

idyedov/sqsconsumer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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()
    );
}

About

A simple SQS consumer with backoff strategy for failure processing.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages