键匹配 - Amazon Simple Notification Service
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

键匹配

您可以使用 exists 运算符来匹配在筛选策略中具有或不具有指定属性的传入消息。exists 匹配只对叶节点有效。它对于中间节点不起作用。

  • 使用 "exists": true 匹配包含指定属性的传入消息。键值必须为非空值。

    例如,以下策略属性使用值为 trueexists 运算符:

    "store": [{"exists": true}]

    它匹配包含 store 属性键的任何消息属性列表,如下所示:

    "store": {"Type": "String", "Value": "fans"} "customer_interests": {"Type": "String.Array", "Value": "[\"baseball\", \"basketball\"]"}

    它还匹配以下任一消息正文:

    { "store": "fans" "customer_interests": ["baseball", "basketball"] }

    但是,它不匹配不含 store 属性键的任何消息属性列表,如下所示:

    "customer_interests": {"Type": "String.Array", "Value": "[\"baseball\", \"basketball\"]"}

    它与以下消息正文也不匹配:

    { "customer_interests": ["baseball", "basketball"] }
  • 使用 "exists": false 匹配 包含指定属性的传入消息。

    注意

    "exists": false 仅在存在至少一个属性时才匹配。一组空的属性会导致筛选条件不匹配。

    例如,以下策略属性使用值为 falseexists 运算符:

    "store": [{"exists": false}]

    匹配包含 store 属性键的任何消息属性列表,如下所示:

    "store": {"Type": "String", "Value": "fans"} "customer_interests": {"Type": "String.Array", "Value": "[\"baseball\", \"basketball\"]"}

    它与以下消息正文也不匹配:

    { "store": "fans" "customer_interests": ["baseball", "basketball"] }

    但是,它匹配不含 store 属性键的任何消息属性列表,如下所示:

    "customer_interests": {"Type": "String.Array", "Value": "[\"baseball\", \"basketball\"]"}

    它还匹配以下消息正文:

    { "customer_interests": ["baseball", "basketball"] }