Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS SNS Message filtering on 'OR' condition

On the SNS Message filtering page there is an example for AND/OR Logic as follows

AND logic : Apply AND logic by using multiple attribute names (keys). For example, the policy:

{
    "customer_interests": ["rugby"],
    "price_usd": [{"numeric":[">", 100]}]
}

OR logic : Apply OR logic by assigning multiple values to an attribute name. For example, the policy attribute:

"customer_interests": ["rugby", "football", "baseball"]

However how can we apply 'OR' logic for multiple attribute names (keys)

So for example what will be the policy if I want to change the first example

From

(customer_interests="rugby" AND price_usd > 100)

To

(customer_interests="rugby" OR price_usd > 100)

like image 337
Arafat Nalkhande Avatar asked Jun 27 '18 09:06

Arafat Nalkhande


People also ask

Can SQS filter messages?

When you subscribe an Amazon SQS FIFO queue to an SNS FIFO topic, you can use message filtering to specify that the subscriber receives a subset of messages, rather than all of them. Each subscriber can set its own filter policy as a subscription attribute.

Does Amazon SNS guarantee that messages are delivered to the subscribed endpoint?

Q: Does Amazon SNS guarantee that messages are delivered to the subscribed endpoint? Yes, as long as the subscribed endpoint is accessible. A message delivery fails when Amazon SNS can't access a subscribed endpoint, due to either a client-side or a server-side error.

What is the format of an SNS endpoint message and what are its properties?

HTTP/HTTPS notification JSON format When Amazon SNS sends a notification to a subscribed HTTP or HTTPS endpoint, the POST message sent to the endpoint has a message body that contains a JSON document with the following name-value pairs. The Message value specified when the notification was published to the topic.

What is message filtering?

Message filtering enables you select the criteria at which you want messages to display in Mailbox Server. Message filtering limits the number of messages and attachments that the system displays. This makes it easier to locate the messages that you want to track.


1 Answers

You would have to create 2 separate subscriptions to same endpoint and attach different filters:

For 1st subscription:

{
    "customer_interests": ["rugby"]
}

For 2nd subscription:

{   
   "price_usd": [{"numeric":[">", 100]}]
}

I didn't find any way of having OR in single filter, but with creating multiple subscriptions to same endpoint definitely works (used it mysqlf on my account)

like image 185
Caldazar Avatar answered Oct 20 '22 11:10

Caldazar