spring-cloud-aws icon indicating copy to clipboard operation
spring-cloud-aws copied to clipboard

SNS Message is Object instead of String JSON

Open grhamuda opened this issue 1 year ago • 1 comments

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

grhamuda avatar Dec 14 '23 10:12 grhamuda

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?

MatejNedic avatar Jan 03 '24 23:01 MatejNedic

Closing due lack of feedback. If someone has same issue please write and we can reopen the issue.

MatejNedic avatar Mar 14 '24 00:03 MatejNedic