Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing SNS attributes when sending a message via SnsTemplate and receiving via @SqsListener #1111

Open
mt-ocado opened this issue Mar 21, 2024 · 0 comments

Comments

@mt-ocado
Copy link
Contributor

mt-ocado commented Mar 21, 2024

Type: Bug

Component: SNS, SQS

Description
Reference documentation mentions that when we receive SNS messages through the @SqsListener, the message includes all attributes of the SnsNotification. However, the attributes are not passed to message headers.

Sample
Having an SQS queue that is subscribed to SNS topic (raw message delivery is disabled), when sending to SNS via snsTemplate as following

 snsTemplate.convertAndSend(topicName, pojo, Map.of("my-attribute", "attribute-value"));

and receiving the message via @SqsListener as following

 @SqsListener("${queueName}")
 public void processGreetingsEvent(Message<?> message){
     System.out.println(message.getHeaders().get("my-attribute"))
 }

then null is printed instead of "attribute-value".

The same effect is seen when receiving as following

@SqsListener("${queue.name}")
public void processGreetingsEvent(@SnsNotificationMessage Pojo pojo, @Headers Map<String, Object> headers) {
    headers.get("my-attribute"))
}

Am I missing something? Is there a way I can access the attributes (I did not find direct information in the documentation).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant