0%
AWS Developer Associate (DVA-C03) Exam Prep: Development, Security, Testing, Deployment and Troubleshooting
How the Exam Works
Domain 2: Security
Domain 3: Testing and Deployment
Domain 4: Troubleshooting and Optimization
New in DVA-C03: Containers and AI
Final Review and Mock Exams
Messaging and Orchestration: SQS, SNS, EventBridge, Kinesis and Step Functions
Amazon Simple Queue Service is the oldest AWS service and still one of the most tested on the Developer Associate exam. The architect exam asks when to put a queue between two tiers. This exam asks what your code does with that queue: which API calls it makes, which parameters it sets, what happens when it crashes halfway through a message and how you stop one bad message from blocking everything. This lesson covers SQS, SNS, EventBridge, Kinesis Data Streams and Step Functions from that point of view. Lambda event source mappings were introduced in the Lambda lesson; here you see the queue and stream side of them.
The life of a message
A producer calls SendMessage (or SendMessageBatch with up to ten entries) with a message body and optional message attributes. SQS stores the message redundantly and returns a MessageId. A consumer calls ReceiveMessage, which returns up to ten messages (MaxNumberOfMessages, default 1). Each received message comes with a ReceiptHandle. The consumer processes the message and then calls DeleteMessage with that receipt handle. Only DeleteMessage removes the message from the queue.
That last point is the one candidates forget. Receiving a message does not remove it. It hides it. The message stays in the queue, invisible to other consumers, for the length of the visibility timeout. If the consumer deletes it in time, it is gone. If the consumer crashes, hangs or simply forgets to delete, the timeout expires and the message becomes visible again for any consumer to receive.
Note that you delete with the receipt handle, not the message ID. The receipt handle belongs to one particular receive. If the same message is received twice, the latest receipt handle is the one to use.
Visibility timeout: sizing it and extending it
The default visibility timeout is 30 seconds and the maximum is 12 hours. You set it on the queue as a default, override it per ReceiveMessage call, or change it for one in-flight message with ChangeMessageVisibility. The rule of thumb is simple: the timeout must be longer than the time your consumer normally needs to finish and delete the message.
If the timeout is too short, a slow but healthy consumer is still working when the message reappears. A second consumer picks it up and does the same work again. The symptom in an exam stem is "orders are occasionally processed twice" or "the same email is sent more than once", with a processing time that is longer than the timeout. The fix is to raise the visibility timeout, or have the consumer call ChangeMessageVisibility periodically to extend it while it works on a long job, which is a heartbeat pattern.
If the timeout is too long, a crashed consumer's message stays hidden for a long time before anyone retries it. That only costs latency, not correctness, so when in doubt err on the long side. When Lambda consumes the queue, AWS recommends a queue visibility timeout of at least six times the function timeout, so that retries inside a batch and throttling do not cause messages to reappear while a function is still working on them.
Setting the visibility timeout to zero on a message with ChangeMessageVisibility makes it visible immediately. That is how a consumer can hand back a message it cannot process right now without waiting for the timeout.
At least once, so make consumers idempotent
A standard queue promises at-least-once delivery and best-effort ordering. Occasionally a message is delivered more than once, even with a correctly sized timeout, because SQS stores copies on several servers. Messages can also arrive out of order. Standard queues trade those guarantees for nearly unlimited throughput.
The developer's answer is an idempotent consumer. Give each business operation a unique key, such as the order ID, and record that it has been done, for example with a DynamoDB conditional write that fails if the key already exists. A second delivery then finds the key and does nothing. The exam likes this answer because it works for every at-least-once system in this lesson: SQS standard, SNS, EventBridge, Lambda async invocations and Kinesis retries.
Short polling, long polling and empty receives
By default ReceiveMessage uses short polling. It queries a subset of the SQS servers and returns immediately, often with no messages even when the queue holds some, and often with an empty response when the queue is idle. Every empty response is still a billed request, and a tight loop of short polls burns money and CPU.
Long polling waits up to WaitTimeSeconds, maximum 20 seconds, for a message to arrive, and it queries all servers. It returns as soon as at least one message is available. You enable it either per call with WaitTimeSeconds or for the whole queue with the ReceiveMessageWaitTimeSeconds attribute. On the exam, "reduce the number of empty responses", "reduce cost of polling" and "reduce latency for consumers that poll an often empty queue" all point to long polling.
Message size, retention and delays
A few numbers shape designs. Message retention defaults to four days and can be set from one minute to fourteen days. The maximum message size was 256 KB for many years and was raised to 1 MiB in 2025; older study material still quotes 256 KB. For anything bigger, store the payload in S3 and send a pointer. The Amazon SQS Extended Client Library for Java (and its Python counterpart) does that for you: it uploads large bodies to S3 and puts a reference in the message, up to about 2 GB.
A delay queue postpones delivery of every new message by DelaySeconds, from 0 to 15 minutes. On a standard queue you can also set a per-message delay with a message timer. Delay is different from visibility timeout. Delay hides a message before anyone receives it for the first time. Visibility timeout hides it after a receive.
Batching cuts cost. SendMessageBatch, DeleteMessageBatch and ChangeMessageVisibilityBatch each take up to ten entries in one request. Batch calls can partly fail: the response lists Successful and Failed entries, and your code must check the Failed list and retry those entries. A batch call that returns HTTP 200 has not necessarily delivered everything.
Scaling consumers on queue depth
For EC2 or container consumers, the CloudWatch metric ApproximateNumberOfMessagesVisible is the backlog. A common pattern is to scale an Auto Scaling group or ECS service on backlog per worker. ApproximateAgeOfOldestMessage tells you how stale the oldest message is, which is the better alarm when latency matters. ApproximateNumberOfMessagesNotVisible counts messages currently in flight. If that number keeps climbing while nothing is deleted, consumers are receiving but failing or forgetting to delete.
What the exam is checking here
Questions on this section are usually a symptom plus four API level fixes. Duplicate processing points to the visibility timeout or to idempotency. Empty responses and high request counts point to long polling. Payloads that are too large point to S3 plus a pointer, or the extended client. Messages that must wait before processing point to a delay queue or message timer. Keep the vocabulary precise, because the wrong options often use the right idea with the wrong parameter, such as setting DelaySeconds to fix duplicate processing.
Message attributes and system attributes
Message attributes are typed name and value pairs (String, Number or Binary) sent alongside the body, up to ten per message. They let consumers route or filter without parsing the body, and they are what SNS filter policies match by default when a topic fans out to queues. System attributes are set by SQS or requested by the consumer: ApproximateReceiveCount, SentTimestamp, ApproximateFirstReceiveTimestamp and, for FIFO queues, MessageGroupId and SequenceNumber. A consumer must ask for them explicitly with MessageSystemAttributeNames (or the older AttributeNames) and MessageAttributeNames on ReceiveMessage; by default none are returned. A consumer that checks ApproximateReceiveCount can log a warning or take a different path on the third attempt, before the message reaches a dead letter queue.
Worked example: an image resizing worker
Picture a fleet of workers that resize uploaded images. Each job takes 5 to 90 seconds. The queue starts with defaults and the team reports duplicate thumbnails and a high bill. Walk through the fixes in order. Long polling with a 20 second wait removes the empty receives that drive the bill. A visibility timeout of about 180 seconds, twice the slowest normal job, stops healthy jobs from reappearing. Writing the thumbnail to a deterministic S3 key derived from the source key makes a duplicate run harmless, because it overwrites the same object. A redrive policy with maxReceiveCount 5 catches corrupt images. Each step is a single setting or a small code change, which is exactly the level the exam asks about.
A message you have received is only hidden for the visibility timeout. If your code does not call DeleteMessage with the receipt handle after finishing, the message comes back and is processed again.