Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

AWS SNS: Add SNS FIFO queues support to NotificationMessagingTemplate: set PublishRequest.messageGroupId and PublishRequest.messageDeduplicationId #777

Closed
dmitry-weirdo opened this issue Jun 15, 2021 · 1 comment
Labels

Comments

@dmitry-weirdo
Copy link

dmitry-weirdo commented Jun 15, 2021

In QueueMessageChannel#prepareSendMessageRequest, there is a special handling of SqsMessageHeaders.SQS_GROUP_ID_HEADER and SqsMessageHeaders.SQS_DEDUPLICATION_ID_HEADER set in the Message#headers map. This allows us to send a message to a FIFO queue.

However, there is no special handling of these headers in TopicMessageChannel, which leads to this exception, when we try to publish to a FIFO SNS queue:

org.springframework.messaging.MessageDeliveryException: Failed to send message to TopicMessageChannel[TopicMessageChannel@3466aafb]; nested exception is com.amazonaws.services.sns.model.InvalidParameterException: Invalid parameter: The MessageGroupId parameter is required for FIFO topics (Service: AmazonSNS; Status Code: 400; Error Code: InvalidParameter; Request ID: e1895f23-cc29-56e5-b08c-066173822a22; Proxy: null)
	at org.springframework.messaging.support.AbstractMessageChannel.send(AbstractMessageChannel.java:149) ~[spring-messaging-5.3.6.jar:5.3.6]
	at org.springframework.messaging.support.AbstractMessageChannel.send(AbstractMessageChannel.java:125) ~[spring-messaging-5.3.6.jar:5.3.6]

We need to add the same handling and set the values of special headers to PublishRequest#messageGroupId and PublishRequest#messageDeduplicationId.

When I do it via pure AWS SDK (publishRequest.setMessageGroupId, publishRequest.setMessageDeduplicationId), the publishing to the same SNS topic is working.

@github-actions github-actions bot added the status: waiting-for-triage An issue we've not yet triaged label Jun 15, 2021
dmitry-weirdo pushed a commit to dmitry-weirdo/spring-cloud-aws that referenced this issue Jun 15, 2021
dmitry-weirdo pushed a commit to dmitry-weirdo/spring-cloud-aws that referenced this issue Jun 15, 2021
dmitry-weirdo pushed a commit to dmitry-weirdo/spring-cloud-aws that referenced this issue Jun 15, 2021
@maciejwalkowiak
Copy link
Contributor

Implemented in awspring/spring-cloud-aws#130

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging a pull request may close this issue.

3 participants