Google Cloud Pub/Sub Starters for gcloud Version v0.15.x
Google Cloud Pub/Sub starters/examples/references for Node.js gcloud version v0.15.x.
Usage:
|
|
Create Topic
|
|
Output:
|
|
This is one way to determine the existence of a topic. If the topic (resource) already exists, an error will be thrown with error code 409
, this is likely originated from HTTP status code 409. Therefore, we can replace the error handling routine with:
|
|
Retrieve Topic
|
|
Output:
|
|
Retrieve Topics
|
|
Output:
|
|
Remove Topic
|
|
Output:
|
|
Remove All Topics
|
|
Output:
|
|
Publish Messages
|
|
Output:
|
|
Create Subscription
|
|
Output:
|
|
From the subscription and topic formats, we can tell that both subscription and topic are unique to the project. Subscription is not unique within the domain of topic. Therefore, if there are two different topics, they still cannot have the same subscription name.
Retrieve Subscription
|
|
Output:
|
|
Retrieve Subscriptions
Since subscription is unique to the project, therefore, we can retrieve all subscriptions of a project additional to retrieving all subscriptions of a topic.
|
|
Output:
|
|
Remove Subscription
|
|
Output:
|
|
Pull Messages
|
|
Output:
|
|
Wait Messages
|
|
Output:
|
|
Acknowledge Message
Do not automatically acknowledge the message, do it when you are actually done with it.
|
|
Output:
|
|