Course menuDVA-C02

Exams / DVA-C02 / Messaging with SQS, SNS and EventBridge / Question 1

DVA-C02 practice question: Messaging with SQS, SNS and EventBridge (1 of 2)

Development with AWS Services 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 AWS Lambda function processes messages from an Amazon SQS standard queue through an event source mapping. The function timeout is 120 seconds and some batches take nearly that long. The queue's visibility timeout is 30 seconds, and the team sees the same messages processed more than once. What should the developer do?

Choose one answer.

  1. A. Raise the queue's visibility timeout to at least six times the function timeout.
  2. B. Reduce the function timeout to 30 seconds so it matches the visibility timeout.
  3. C. Convert the queue to a FIFO queue to guarantee exactly-once processing.
  4. D. Enable long polling on the queue by setting a receive message wait time.
Show the answer and explanation

Answer: A

  • A. Right: Correct. Messages stay hidden while the batch is processed, and AWS recommends six times the function timeout to allow for throttling retries.
  • B. Wrong: Batches that need close to 120 seconds would then time out and fail, causing even more retries.
  • C. Wrong: A FIFO queue does not stop a message reappearing when its visibility timeout ends before processing finishes.
  • D. Wrong: Long polling reduces empty receives. It has no effect on how long a received message stays hidden.

Explanation

When a consumer receives a message, SQS hides it only for the visibility timeout. If processing takes longer, the message becomes visible again and is delivered a second time. For Lambda event source mappings, AWS recommends a visibility timeout of at least six times the function timeout, and Lambda rejects a mapping where the function timeout exceeds the visibility timeout.

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.