Google Professional Cloud Developer Question 409
Select 4Google Cloud PlatformYou are developing an application that processes real-time financial transactions and publishes notifications about suspicious activity. The application uses Google Cloud Pub/Sub for asynchronous communication. To ensure reliable message handling, what steps should you take when implementing the subscriber's processing logic?
- A
Acknowledge the message only after the processing of the message is complete.
- B
Use a Pull subscription type to retrieve messages and control the processing flow.
- C
Use a Push subscription type to simplify message processing and let Pub/Sub manage retries.
- D
Implement retry logic in the subscriber to handle transient failures during message processing.
- E
Set a custom acknowledgment deadline in the subscriber to accommodate the time required for processing complex messages.
Show answer and explanation
Correct answers: A, B, D, E
Explanation
To ensure reliable message handling in a Pub/Sub subscriber, it is important to acknowledge messages only after successful processing, use a Pull subscription for greater control, implement retry logic for transient errors, and customize acknowledgment deadlines for long-running tasks. Push subscriptions, while easier to set up, lack the fine-grained control needed for critical applications like financial transaction processing.
- A. Correct.
Acknowledging the message only after processing ensures that the message isn't removed from the subscription before successful handling, reducing the risk of losing unprocessed messages.
- B. Correct.
Using a Pull subscription gives you control over the flow of messages and processing logic, which is crucial for applications requiring precise error handling and retries.
- C. Incorrect.
While Push subscriptions simplify message delivery, they don't provide as much control over processing flow and retry logic, which are important for reliability in critical applications like financial systems.
- D. Correct.
Retry logic is essential for handling transient errors (e.g., network interruptions or temporary unavailability of external systems) to ensure reliable message processing.
- E. Correct.
Setting a custom acknowledgment deadline allows the subscriber to process complex messages without exceeding the default deadline, preventing premature redelivery of the message.