Send Object as sns message attribute

0

I'd like to publish a message to my sns topic.
I'm using js "aws-sdk/client-sns" with the snsClient.send(new PublishCommand(params).
Subscribed to my sns topic there is a sqs queue with a filter sub policy.
The issue is with the message attributes, I want to send as value a json object as in this example:
MessageAttributes: { filter: { DataType: 'String', StringValue: "filter" } }, object: { DataType: 'String', StringValue: JSON.stringify( object ) } }
the message never get to the queue and fails under "NumberOfNotificationsFilteredOut" or "NumberOfNotificationsFilteredOut-InvalidAttributes".
Instead, if the queue does not have a filter sub policy or I set the object as DataType: 'String.Array'the message arrive without any problem, is this a bug? How should I set my message attribute if I want to send an Object ? Thanks.

1개 답변
0

Amazon SNS compares policy attributes only to message attributes that have the following data types:

  1. String
  2. String.Array
  3. Number

for more details see: https://docs.aws.amazon.com/sns/latest/dg/subscription-filter-policy-constraints.html

답변함 2년 전
  • Thanks for the info, but this is not what I'm looking for, I want to know if there is a correct way to send an Object as a message attribute, and why if sent as "DataType: String" is messing up with the filter policy, while with "String.Array" there is no problem.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠