Lambda订阅SNS主题时,消息属性为什么以字符串形式传递的数字?

0

【以下的问题经过翻译处理】 我在一个SNS主题上有两个订阅者,一个是JSON-email,另一个是Lambda。当我发送一条带有数字类型的MessageAttributes的消息时,我的JSON-email中会以数字的形式得到它们,但在我的Lambda事件中却以字符串的形式得到。同一条消息,同一条messageId看起来像这样:

  "MessageAttributes" : {
    "Active" : {"Type":"Number","Value":"0"}
  }

  "MessageAttributes" : {
    "Active" : {"Type":"String","Value":"0"}
  }

这是一个bug吗,还是我做错了什么?

profile picture
EXPERT
demandé il y a 5 mois15 vues
1 réponse
0

【以下的回答经过翻译处理】 根据AWS文档,将Number类型的SNS消息属性发送到Lambda事件时会作为String类型处理,这不是bug。 https://docs.aws.amazon.com/sns/latest/dg/sns-message-attributes.html

AWS Lambda订阅不支持Number数据类型。如果您为Lambda端点指定此数据类型,则会在Amazon SNS传递给Lambda的JSON负载中以String数据类型传递。

profile picture
EXPERT
répondu il y a 5 mois

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions