I am trying to send a message to the FIFO SQS queue using the below code snippet:
Message<String> message = MessageBuilder.withPayload("1234")
.setHeader("message-group-id", "1")
.setHeader("message-deduplication-id", "1")
.build();
Map<String, Object> messageHeaderMap =
Map.of("message-group-id", "1",
"message-deduplication-id", "1")
queueMessagingTemplate.convertAndSend(new QueueMessageChannel(amazonSQSAsync, queueUrl), message, messageHeaderMap);
Actually, for being on the safer side, I set the attributes both in map and Message
. In spite of this, I am getting the following error message:
org.springframework.messaging.MessageDeliveryException: The request must
contain the parameter MessageGroupId. (Service: AmazonSQS; Status Code: 400;
Error Code: MissingParameter; Request ID: 9510767b-3be2-59a8-9fc6-2b6f48c0591c;
Proxy: null); nested exception is
com.amazonaws.services.sqs.model.AmazonSQSException: The request must contain t
the parameter MessageGroupId. (Service: AmazonSQS; Status Code: 400; Error
Code: MissingParameter; Request ID: 9510767b-3be2-59a8-9fc6-2b6f48c0591c; Proxy:
null)
I am basically clueless regarding how to fix this. Could anyone please help here?
EDIT
I have refactored the above code as per the suggestion as follows:
Message<String> message = MessageBuilder.withPayload("1234")
.setHeader("message-group-id", "1")
.setHeader("message-deduplication-id", "1")
.setHeader("messageGroupId", "1")
.setHeader("messageDeduplicationId", "1").build();
Map<String, Object> messageHeaderMap = Map.of("message-group-id", messageGroupId,
"MessageGroupId", "1",
"message-deduplication-id", "1",
"messageGroupId", "1",
"messageDeduplicationId", "1")
queueMessagingTemplate.convertAndSend(sqsMessageChannel, message, messageHeaderMap);
But, still getting the exact same error.