Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring cloud AWS - send message to fifo queue

I'm using spring-cloud-aws to send a message to SQS FIFO queue.

It's failing with

The request must contain the parameter MessageGroupId

There doesn't seem to be anywhere on the QueueMessagingTemplate in spring-cloud-aws-messaging that allows me to set this mandatory MessageGroupId.

Is there currently a way of writing to a SQS FIFO queue in this manor or would I have to revert to directly using amazons API?

like image 998
Rich Croft Avatar asked Nov 21 '25 09:11

Rich Croft


1 Answers

Spring Cloud AWS support FIFO queues since 2017, in accordance with: Add Support for FIFO SQS Queues #252

You just need to add the two required params(messageGroupId and messageDeduplicationId) like example below:

public void send(String topicName, Object message, String messageGroupId, String messageDeduplicationId) throws MessagingException {
    Map<String, Object> headers = new HashMap<>();
    headers.put("message-group-id", messageGroupId);
    headers.put("message-deduplication-id", messageDeduplicationId);
    messagingTemplate.convertAndSend(topicName, message, headers);
}
like image 197
otavaresgabriel Avatar answered Nov 24 '25 07:11

otavaresgabriel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!