0

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.

Joy
  • 4,197
  • 14
  • 61
  • 131
  • 1
    Looks like a typo... `meesage` is not `message` (in `meesage-group-id`) – Phil Jun 27 '23 at 05:58
  • Might help... [Spring Cloud AWS](https://docs.awspring.io/spring-cloud-aws/docs/3.0.0/reference/html/index.html) says _"To send messages to a Fifo queue, the options include `messageDeduplicationId` and `messageGroupId` properties. If either values are not provided, a random UUID is generated. The generated values can be retrieved in the headers of the Message contained in the `SendResult` object."_ – John Rotenstein Jun 27 '23 at 06:00
  • @JohnRotenstein in spite of renaming the attributes, it did not help, getting the same error. Completely clueless!! – Joy Jun 27 '23 at 06:45

0 Answers0