Course menuDVA-C02

Exams / DVA-C02 / Caching and message filtering / Question 1

DVA-C02 practice question: Caching and message filtering

Troubleshooting and Optimization A free question from our original DVA-C02 practice exam. Try it, then open the answer to see why each option is right or wrong.

An SNS topic receives order events. A shipping service's SQS queue is subscribed to the topic with this filter policy, using the default message attributes scope: { "eventType": ["order_shipped"] } The publisher sets eventType as a message attribute. Which published message is delivered to the shipping queue?

Choose one answer.

  1. A. A message whose body contains "eventType": "order_shipped" but with no message attributes.
  2. B. A message with the eventType attribute set to order_created.
  3. C. A message with the eventType attribute set to order_shipped.
  4. D. Every message, because filter policies only add attributes to delivered messages.
Show the answer and explanation

Answer: C

  • A. Wrong: With the default scope, the policy is matched against message attributes, not the body, so this message is not delivered.
  • B. Wrong: The attribute value does not match the policy, so SNS does not deliver it to this subscription.
  • C. Right: Correct. The attribute matches the filter policy, so SNS delivers the message to this subscriber.
  • D. Wrong: Filter policies decide which messages a subscriber receives. Messages that do not match are not sent to it.

Explanation

By default, every subscriber to an SNS topic receives every message. A filter policy on a subscription limits delivery to messages whose attributes, or JSON body if the scope is MessageBody, match the policy. Filtering in SNS saves consumers from receiving and discarding messages they do not need.

Study

Keep practising

Answer questions with a score at the end, or practise just this topic with the explanation after each one. No sign-up needed.