xaxaxaxaxa
xaxaxaxaxa

Reputation: 1

How to filtering message with AWS SNS with Ruby on Rails

I'm using 'aws-sdk' gem.

https://github.com/aws/aws-sdk-ruby

Using below gem

'aws-sdk (1.11.0)'

I want to use filtering messages function.

https://docs.aws.amazon.com/sns/latest/dg/message-filtering.html

I understood I should set Filter policy.

but, I could not find how to set it.

I have read below.

https://docs.aws.amazon.com/sdk-for-ruby/v3/developer-guide/sns-examples.html https://docs.aws.amazon.com/sdk-for-ruby/v3/api/index.html

How can I use this function?

Thank you.

Upvotes: 0

Views: 492

Answers (1)

xaxaxaxaxa
xaxaxaxaxa

Reputation: 1

I could set FilterPolicy using set_subscription_attributes.
DeliveryPolicy and RawMessageDelivery were valid attribute names in the description of this page, and FilterPolicy could be used too.

https://docs.aws.amazon.com/sdkforruby/api/Aws/SNS/Client.html#set_subscription_attributes-instance_method

params = {subscription_arn: subscription_arn, attribute_name: 'FilterPolicy', attribute_value: '{"event_type": ["order_placed", "order_cancelled"]}'}
client.set_subscription_attributes(params)

Upvotes: 0

Related Questions