From a2ad6c00086dbe9d8e3e747a8ef480046d35497b Mon Sep 17 00:00:00 2001 From: Maciej Walkowiak Date: Mon, 30 Oct 2023 14:20:48 +0100 Subject: [PATCH] Set more detailed data type on "timestamp" attribute in SNS message. (#932) Mainly due to keeping backward compatibility with Spring Cloud AWS 2.x Fixes #791 --- .../java/io/awspring/cloud/sns/core/TopicMessageChannel.java | 2 +- .../io/awspring/cloud/sns/core/TopicMessageChannelTest.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-cloud-aws-sns/src/main/java/io/awspring/cloud/sns/core/TopicMessageChannel.java b/spring-cloud-aws-sns/src/main/java/io/awspring/cloud/sns/core/TopicMessageChannel.java index 22e9d50cf..4e9eed44a 100644 --- a/spring-cloud-aws-sns/src/main/java/io/awspring/cloud/sns/core/TopicMessageChannel.java +++ b/spring-cloud-aws-sns/src/main/java/io/awspring/cloud/sns/core/TopicMessageChannel.java @@ -103,7 +103,7 @@ else if (MessageHeaders.ID.equals(messageHeaderName) && messageHeaderValue != nu messageAttributes.put(messageHeaderName, getStringMessageAttribute(messageHeaderValue.toString())); } else if (MessageHeaders.TIMESTAMP.equals(messageHeaderName) && messageHeaderValue != null) { - messageAttributes.put(messageHeaderName, getNumberMessageAttribute(messageHeaderValue)); + messageAttributes.put(messageHeaderName, getDetailedNumberMessageAttribute(messageHeaderValue)); } else if (messageHeaderValue instanceof String) { messageAttributes.put(messageHeaderName, getStringMessageAttribute((String) messageHeaderValue)); diff --git a/spring-cloud-aws-sns/src/test/java/io/awspring/cloud/sns/core/TopicMessageChannelTest.java b/spring-cloud-aws-sns/src/test/java/io/awspring/cloud/sns/core/TopicMessageChannelTest.java index d47fe208b..3c0009ae0 100644 --- a/spring-cloud-aws-sns/src/test/java/io/awspring/cloud/sns/core/TopicMessageChannelTest.java +++ b/spring-cloud-aws-sns/src/test/java/io/awspring/cloud/sns/core/TopicMessageChannelTest.java @@ -66,6 +66,7 @@ void sendMessage_validTextMessageAndSubject_returnsTrue() throws Exception { assertThat(it.topicArn()).isEqualTo(TOPIC_ARN); assertThat(it.message()).isEqualTo("Message content"); assertThat(it.messageAttributes()).containsKeys(MessageHeaders.ID, MessageHeaders.TIMESTAMP); + assertThat(it.messageAttributes().get(MessageHeaders.TIMESTAMP).dataType()).isEqualTo("Number.java.lang.Long"); assertThat(it.messageAttributes()).doesNotContainKey(NOTIFICATION_SUBJECT_HEADER); })); assertThat(sent).isTrue();