
Answer-first summary for fast verification
Answer: Define a schema and associate it with a topic at the time of the topic's creation.
Schemas are designed to specify a standard message format and are associated with topics upon their creation. It's important to note that schemas cannot be assigned to subscriptions. Leveraging Cloud Functions for this purpose is unnecessary since Cloud Pub/Sub inherently supports this feature. Additionally, Cloud Functions are limited to handling only one type of Pub/Sub event, specifically `google.pubsub.topic.publish`. For more details, refer to [Cloud Pub/Sub Schemas documentation](https://cloud.google.com/pubsub/docs/schemas).
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
No comments yet.
As part of the ingestion process, you want to ensure any messages written to a Cloud Pub/Sub topic all have a standard structure. What is the recommended way to ensure messages have the standard structure?
A
Implement a data quality function within a Cloud Function to reformat the message as necessary before it is consumed from a subscription.
B
Define a schema and associate it with a topic at the time of the topic's creation.
C
Utilize a data quality function in a Cloud Function to verify the message structure upon writing to Cloud Pub/Sub.
D
Establish a schema and link it to a subscription during the subscription's creation.