spring-cloud-aws
spring-cloud-aws copied to clipboard
SNS Message is Object instead of String JSON
Type: Bug
Component: SNS
Describe the bug
I'm migrating from spring boot 2.X to 3.X and changing from aws sdk v1 to v2.
One of the changes is using SnsTemplate
instead of notificationMessagingTemplate
public void notifySubscriber(ProviderProductPublishingData productPublishingData) {
messageAttributes.put(SnsHeaders.NOTIFICATION_SUBJECT_HEADER, "Product Publish Data");
messageAttributes.put(MessageHeaders.CONTENT_TYPE, "application/json");
SnsNotification<ProviderProductPublishingData> notification = new SnsNotification<>(productPublishingData, convertMap(messageAttributes));
snsTemplate.sendNotification(topicArn, notification);
log.info("notifySubscriber {} {}", topicArn, gson.toJson(notification));
}
somehow the code above will send the payload as String object instead of String JSON.
i.e. productPublishingData=[name=product_name]
instead of {name="product_name"}
Am I missing something on my implementation ?
Sample on description
Hey @mgrahadhuita , sorry for late response could you please provide a sample?
We have test covering this and they are passing fine. Even I can't reproduce your issue with my test app. Are, you by any chance using custom Converter when creating SnsTemplate
?
Closing due lack of feedback. If someone has same issue please write and we can reopen the issue.