I am currently working with SNS and SQS to integrate disparate remote systems. The producer sends messages to an AWS SNS with a SQS subscribed. The consumer is a Spring Boot application with spring integration enabled that polls the SQS with an @SqsListener (default configuration with no tweaking). All this works fine.
The requirement is to process those messages in the right order mostly driven by the chronological creation time from the producer perspective. And as some of they could be dependent I have to process them one by one taking into account the original order.
The problem is that I am aware that SQS does not guarantees that those messages arrive in order when the Listener polls the SQS. I have probe this by programmatically sending a couple of messages to the SNS in the right order I want them to be processed and receive those messages in a slightly different order within the SqsListener.
To try to deal with this unwanted effect I put in place a Priority Channel right after the SqsListener to buffer those messages and let this channel reorder the messages.
Would this be the right approach to process standard SQS messages in order? Should I tweak the Listener config, for example to change it for a Long Polling?