Bird
0
0

How do you publish a message with an ordering key in Google Cloud Pub/Sub using Python?

easy📝 Syntax Q3 of 15
GCP - Cloud Pub/Sub

How do you publish a message with an ordering key in Google Cloud Pub/Sub using Python?

Apublisher.publish(topic_path, data, message_order='key1')
Bpublisher.publish(topic_path, data, key='key1')
Cpublisher.publish(topic_path, data, order='key1')
Dpublisher.publish(topic_path, data, ordering_key='key1')
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct parameter

    The correct parameter to specify ordering key is ordering_key.
  2. Step 2: Check syntax

    publisher.publish(topic_path, data, ordering_key='key1') uses ordering_key='key1' correctly. Other options use incorrect parameter names.
  3. Final Answer:

    publisher.publish(topic_path, data, ordering_key='key1') -> Option D
  4. Quick Check:

    Use 'ordering_key' parameter [OK]
Quick Trick: Use 'ordering_key' parameter to enable ordering [OK]
Common Mistakes:
  • Using incorrect parameter names like 'key' or 'order'
  • Omitting the ordering_key parameter
  • Confusing ordering_key with message attributes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GCP Quizzes