Bird
Raised Fist0
GCPcloud~20 mins

Dead letter topics in GCP - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Dead Letter Topic Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Purpose of Dead Letter Topics in Pub/Sub

What is the main purpose of a dead letter topic in Google Cloud Pub/Sub?

ATo store messages that failed to be delivered after multiple attempts for later analysis or reprocessing.
BTo route all incoming messages to multiple subscribers simultaneously.
CTo automatically delete messages that are successfully processed to save storage space.
DTo encrypt messages before they are published to the main topic.
Attempts:
2 left
💡 Hint

Think about what happens to messages that cannot be processed properly.

❓ Configuration
intermediate
2:00remaining
Configuring Dead Letter Topic in Pub/Sub Subscription

Which configuration snippet correctly sets a dead letter topic for a Pub/Sub subscription using gcloud CLI?

Agcloud pubsub subscriptions create my-sub --topic=my-topic --dead-letter-topic=my-dead-letter-topic --max-delivery-attempts=5
Bgcloud pubsub subscriptions create my-sub --topic=my-topic --dead-letter-topic=my-topic --max-delivery-attempts=5
Cgcloud pubsub subscriptions create my-sub --topic=my-topic --dead-letter-topic=my-dead-letter-topic
Dgcloud pubsub subscriptions create my-sub --topic=my-topic --max-delivery-attempts=5
Attempts:
2 left
💡 Hint

Remember to specify both the dead letter topic and max delivery attempts.

❓ Architecture
advanced
2:30remaining
Designing a Reliable Message Processing System with Dead Letter Topics

You want to design a Pub/Sub system that processes messages reliably and handles failures gracefully. Which architecture best uses dead letter topics?

AUse multiple subscriptions on the main topic without dead letter topics, relying on automatic retries only.
BUse a main topic with a subscription that has a dead letter topic configured. Failed messages go to the dead letter topic for separate processing and alerting.
CSend all messages directly to a dead letter topic and process them immediately.
DUse a single subscription without dead letter topics and discard messages after one failed attempt.
Attempts:
2 left
💡 Hint

Consider how to separate failed messages for special handling.

❓ security
advanced
2:00remaining
Permissions Required for Dead Letter Topics

Which IAM role must a Pub/Sub subscription have on the dead letter topic to successfully publish failed messages?

Aroles/pubsub.editor
Broles/pubsub.subscriber
Croles/pubsub.publisher
Droles/pubsub.viewer
Attempts:
2 left
💡 Hint

Think about what action the subscription performs on the dead letter topic.

❓ service_behavior
expert
2:30remaining
Behavior of Message Delivery with Dead Letter Topics

Consider a Pub/Sub subscription with a dead letter topic configured and max delivery attempts set to 3. What happens when a message fails processing 3 times?

AThe message is sent to the dead letter topic only after the 4th failed attempt.
BThe message is retried indefinitely until acknowledged, ignoring the max delivery attempts.
CThe message is deleted silently after the 3rd failed attempt without being sent to the dead letter topic.
DThe message is sent to the dead letter topic after the 3rd failed attempt and is not redelivered to the subscription.
Attempts:
2 left
💡 Hint

Recall how max delivery attempts relate to dead letter topic delivery.

Practice

(1/5)
1. What is the main purpose of a dead letter topic in Google Cloud Pub/Sub?
easy
A. To store all successfully delivered messages
B. To speed up message delivery
C. To catch messages that fail delivery multiple times
D. To encrypt messages before sending

Solution

  1. Step 1: Understand message delivery failures

    Messages that cannot be delivered after several attempts need special handling to avoid blocking the main flow.
  2. Step 2: Role of dead letter topics

    Dead letter topics collect these failed messages separately so the main topic stays clean and reliable.
  3. Final Answer:

    To catch messages that fail delivery multiple times -> Option C
  4. Quick Check:

    Dead letter topic = catch failed messages [OK]
Hint: Dead letter topics catch failed messages only [OK]
Common Mistakes:
  • Thinking dead letter topics speed delivery
  • Confusing dead letter topics with encryption
  • Assuming they store successful messages
2. Which block in a Pub/Sub subscription configuration is used to set a dead letter topic?
easy
A. message_storage_policy
B. retry_policy
C. ack_deadline_seconds
D. dead_letter_policy

Solution

  1. Step 1: Identify configuration blocks for subscriptions

    Pub/Sub subscriptions have specific blocks for retry, dead letter, and storage policies.
  2. Step 2: Locate dead letter topic setting

    The dead_letter_policy block is where you specify the dead letter topic and max delivery attempts.
  3. Final Answer:

    dead_letter_policy -> Option D
  4. Quick Check:

    Dead letter topic set in dead_letter_policy [OK]
Hint: Dead letter topic is in dead_letter_policy block [OK]
Common Mistakes:
  • Confusing with retry_policy block
  • Using message_storage_policy incorrectly
  • Setting dead letter topic in ack_deadline_seconds
3. Given this subscription config snippet:
{
  "dead_letter_policy": {
    "dead_letter_topic": "projects/myproj/topics/dlt",
    "max_delivery_attempts": 5
  }
}

What happens when a message fails delivery 6 times?
medium
A. The message is retried indefinitely
B. The message is sent to the dead letter topic
C. The message is deleted immediately
D. The message is sent back to the main topic

Solution

  1. Step 1: Understand max_delivery_attempts meaning

    Messages are retried up to the max_delivery_attempts count before moving to dead letter topic.
  2. Step 2: Apply max_delivery_attempts = 5

    After 5 failed attempts, the 6th failure triggers sending the message to the dead letter topic.
  3. Final Answer:

    The message is sent to the dead letter topic -> Option B
  4. Quick Check:

    Failures > max_delivery_attempts = dead letter send [OK]
Hint: Messages move to dead letter after max attempts exceeded [OK]
Common Mistakes:
  • Thinking messages retry forever
  • Assuming immediate deletion on failure
  • Believing message returns to main topic
4. You configured a dead letter topic but messages are not appearing there after failures. What is a likely cause?
medium
A. Dead letter topic does not exist or lacks permissions
B. max_delivery_attempts is set to 1
C. Subscription ack deadline is too long
D. Main topic has no messages

Solution

  1. Step 1: Check dead letter topic existence and permissions

    If the dead letter topic is missing or the subscription lacks publish permission, messages cannot be sent there.
  2. Step 2: Understand other options

    max_delivery_attempts=1 means one try before dead letter, ack deadline affects delivery timing, and main topic empty means no messages to fail.
  3. Final Answer:

    Dead letter topic does not exist or lacks permissions -> Option A
  4. Quick Check:

    Dead letter topic must exist and be accessible [OK]
Hint: Dead letter topic must exist and allow publishing [OK]
Common Mistakes:
  • Ignoring permissions errors
  • Confusing ack deadline with dead letter setup
  • Assuming empty main topic causes dead letter issues
5. You want to ensure messages that fail more than 3 times go to a dead letter topic, but also want to limit the total retry time to 10 minutes. Which configuration approach is best?
hard
A. Set dead_letter_policy.max_delivery_attempts to 3 and configure retry_policy.minimum_backoff and maximum_backoff to limit retry duration
B. Set dead_letter_policy.max_delivery_attempts to 10 and rely on ack deadline for timing
C. Only set retry_policy.maximum_backoff to 10 minutes without dead letter policy
D. Set dead_letter_policy.max_delivery_attempts to 3 and disable retries

Solution

  1. Step 1: Use max_delivery_attempts to limit retries

    Setting max_delivery_attempts to 3 ensures messages move to dead letter after 3 failed deliveries.
  2. Step 2: Control retry timing with retry_policy

    Configuring minimum and maximum backoff controls how long retries take, helping keep total retry time within 10 minutes.
  3. Step 3: Evaluate other options

    Set dead_letter_policy.max_delivery_attempts to 10 and rely on ack deadline for timing ignores retry timing, C lacks dead letter handling, and D disables retries which may lose messages prematurely.
  4. Final Answer:

    Set dead_letter_policy.max_delivery_attempts to 3 and configure retry_policy minimum and maximum backoff -> Option A
  5. Quick Check:

    Combine max_delivery_attempts and retry_policy for retries and dead letter [OK]
Hint: Use max_delivery_attempts plus retry_policy for timing control [OK]
Common Mistakes:
  • Ignoring retry_policy for timing
  • Disabling retries loses messages
  • Setting max_delivery_attempts too high
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard