Skip to content

[SNS] the timestamp added by Spring as a long attribute in the SNS message makes SNS throw an exception #1441

Description

@fgaume

Type: Bug

Component: SNS

Describe the bug

Spring Cloud AWS 3.4.0 with Spring Boot 3.5.4 and Java 21
I successfully sent a SNS notification using the basic SnsClient (see code below)
But as soon as I use SnsOperations or SnsTemplate, I always get an exception saying that the timestamp attribute has un unexpected type (spring's timestamp, I don't add any attribute) :

org.springframework.messaging.MessageDeliveryException: Failed to send message to TopicMessageChannel[TopicMessageChannel@58a67f97], failedMessage=GenericMessage [payload={"id":6789942,"firstName":"Lourdes","lastName":"Grimes","emailId":"Lourdes.Grimes@bechtelar.com"}, headers={message-deduplication-id=.., message-group-id=.., id=77531181-8020-b056-cea1-f3b5b68fbcef, contentType=text/plain;charset=UTF-8, **timestamp=1755790334457**}]] with root cause

software.amazon.awssdk.services.sns.model.InvalidParameterException: The message attribute 'timestamp' has an invalid message attribute type, the set of supported type prefixes is Binary, Number, and String. (Service: Sns, Status Code: 400, Request ID: l3hkIydpomjCCYx38fBVUplFEUcX0as3m565QwdHRVBuO8TTZIm1)

It seems the AWS SDK expects a String like "2025-08-08 ...." but gets a long like 1755790334457

Sample
Exactly the code from the official documentation.
SnsClient works ok :

String messagePayload = objectMapper.writeValueAsString(employee);
        snsClient.publish(request -> request.topicArn("arn:aws:sns:eu-west-1:123456789012:order-events-topic").message(messagePayload));

SnsOperations failed:

        SnsNotification<Employee> notification = SnsNotification.builder(
                employee)
                .deduplicationId("..")
                .groupId("..")
                .build();
        snsOperations.sendNotification("arn:aws:sns:eu-west-1:123456789012:order-events-topic", notification);

Metadata

Metadata

Assignees

No one assigned

    Labels

    component: snsSNS integration related issuetype: bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions