Created
May 5, 2018 12:04
-
-
Save goungoun/6f593f866fbf73ab2f99ac24cf93e37e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# gcloud beta pubsub topics create sanidego | |
# gcloud beta pubsub topics publish sandiego "hello" | |
from google.cloud import pubsub | |
client = pubsub.Client() | |
topic = client.topic("sandiego") | |
topic.create() | |
topic.publish(b'hello') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Publish a single message to a topic, with attributes
topic.publish(b'Another message payload', extra='EXTRA')
Publish a set of message to a topic (as a single request):
with topic.batch() as batch:
batch.publish(PAYLOAD1)
batch.publiish(PAYLOAD2, extra=EXTRA)