spring-attic / spring-cloud-aws

All development has moved to https://github.com/awspring/spring-cloud-aws Integration for Amazon Web Services APIs with Spring
https://awspring.io/
Apache License 2.0
589 stars 376 forks source link

Unable to publish message on SNS fifo topic, getting "Invalid parameter: The MessageGroupId parameter is required for FIFO topics" error #759

Closed amitgupta9501 closed 3 years ago

amitgupta9501 commented 3 years ago

Type: Bug

Component: "SNS"

Issue description Unable to publish message on SNS fifo topic, getting "Invalid parameter: The MessageGroupId parameter is required for FIFO topics" error

Hi Team,

I have created a SNS fifo topic. I am getting below error from AWS CLI:-

aws sns publish --topic-arn arn:aws:sns:us-east-2:461234567890:testTopic.fifo --message "Hello World!"

ERROR: An error occurred (InvalidParameter) when calling the Publish operation: Invalid parameter: The MessageGroupId parameter is required for FIFO topics

and from aws java sdk also: https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javav2/example_code/sns/src/main/java/com/example/sns/PublishTopic.java

I had changed topicArn to sns fifo topic arn, which is throwing "Invalid parameter: The MessageGroupId parameter is required for FIFO topics"

Please note i am unable to set MessageGroupId in PublishRequest as shown in below AWS documentation:- https://docs.amazonaws.cn/en_us/sns/latest/dg/fifo-topic-code-examples.html

Please share aws java jdk version, where i can set MessageGroupId in PublishRequest.

This issue is similar to https://github.com/spring-cloud/spring-cloud-aws/issues/714

Thanks in advance.

amitgupta9501 commented 3 years ago

Hi Team,

With SNS java sdk upgrade to 'software.amazon.awssdk:sns:2.15.58', which had been released on Jan 04, 2021.

Now able to publish on sns fifo topic with messageGropuId with java sdk. Below error had gone now:-

Invalid parameter: The MessageGroupId parameter is required for FIFO topics

SNS mvn repo url: https://mvnrepository.com/artifact/software.amazon.awssdk/sns/2.15.58

Sample code:

          PublishRequest request = PublishRequest.builder()
                .message(message)
                .topicArn(topicArn)
                .messageGroupId("messageGroupId1")
                .messageDeduplicationId("messageDeduplicationId1")
                .build();

I am closing this ticket now.

Thanks,

sheetaljajoo commented 3 years ago

I am still facing the issue on aws lambda node js code, lambda will get the sdk version automatically i suppose? or do i need to upgrade? how do i do it?