Bird
0
0

Consider this Cloud Function triggered by a Pub/Sub topic named 'updates'. What will happen when a message is published to 'updates'?

medium📝 service behavior Q13 of 15
GCP - Cloud Functions
Consider this Cloud Function triggered by a Pub/Sub topic named 'updates'. What will happen when a message is published to 'updates'?
exports.processUpdate = (event, context) => {
  const message = Buffer.from(event.data, 'base64').toString();
  console.log(`Received message: ${message}`);
};
AThe function ignores the message and does nothing
BThe function throws an error due to missing parameters
CThe function logs the decoded message content
DThe function logs the raw base64 message without decoding
Step-by-Step Solution
Solution:
  1. Step 1: Understand event data decoding

    The function decodes the base64 event.data to a string and logs it.
  2. Step 2: Check function behavior on message publish

    When a message is published, the function runs and logs the decoded message content.
  3. Final Answer:

    The function logs the decoded message content -> Option C
  4. Quick Check:

    Pub/Sub event data decoded and logged [OK]
Quick Trick: Pub/Sub data is base64 decoded before use [OK]
Common Mistakes:
  • Forgetting to decode base64 data
  • Assuming function errors without checking code
  • Thinking function ignores messages

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GCP Quizzes