0

How to control request with SQS. Suppose 4 request submitted in a same time in SQS, then only need to process one at a time. Once first is completes take second request from queue in process, and this process needs to continue.

I was using @SqsListener in springboot to get message payload.

Gregor Zurowski
  • 2,222
  • 2
  • 9
  • 15
developer
  • 21
  • 2

1 Answers1

0

You can define a SimpleMessageListenerContainerFactory bean and configure the listener behavior as follows:

@Bean
public SimpleMessageListenerContainerFactory simpleMessageListenerContainerFactory(AmazonSQSAsync amazonSqs) {
    SimpleMessageListenerContainerFactory factory = new SimpleMessageListenerContainerFactory();
    [...]
    factory.setAmazonSqs(amazonSqs);
    factory.setMaxNumberOfMessages(1);
    [...]

    return factory;
}
Gregor Zurowski
  • 2,222
  • 2
  • 9
  • 15