Skip to content
Back to main site

Pub/Sub walkthrough

Send a message through Pub/Sub on the emulator: create a topic and a subscription, publish hello, pull it back and acknowledge it, then delete what you made. Each step shows the output to expect. The steps were run against Vera 1.2.3 on 9 November 2026. The outputs shown were captured in an earlier run, and their IDs and times differ on every run.

  • A running emulator. Start Vera as described in Get started. Pub/Sub is included in the Free plan.
  • gcloud or curl. The gcloud steps were run with gcloud 585.0.0. The REST steps use curl, plus python3 to copy an ID from one response into the next request. Pub/Sub on the emulator is REST only, so client libraries that use gRPC by default won’t connect.
  • No Google Cloud account. The emulator doesn’t check credentials, and no real project is needed. This walkthrough uses example-project.

Run these in a terminal of their own, so this setup doesn’t mix with your real Google Cloud work. They use Google Cloud’s address on your machine, as published in Get started: if you published another host port, use that one.

Turn off credentials, pick the project and send Pub/Sub requests to the emulator. The Service Usage and Resource Manager lines keep the helper calls some gcloud commands make on the emulator too.

Terminal window
export VERA_ENDPOINT="http://localhost:8081"
export CLOUDSDK_AUTH_DISABLE_CREDENTIALS=true
export CLOUDSDK_CORE_PROJECT=example-project
export CLOUDSDK_API_ENDPOINT_OVERRIDES_SERVICEUSAGE="$VERA_ENDPOINT/_gcp/serviceusage/"
export CLOUDSDK_API_ENDPOINT_OVERRIDES_CLOUDRESOURCEMANAGER="$VERA_ENDPOINT/_gcp/cloudresourcemanager/"
export CLOUDSDK_API_ENDPOINT_OVERRIDES_PUBSUB="$VERA_ENDPOINT/_gcp/pubsub/"

A subscription receives the messages published to its topic, so create the topic first.

Terminal window
gcloud pubsub topics create example-topic --quiet
gcloud pubsub subscriptions create example-subscription --topic=example-topic --quiet
Output
Created topic [projects/example-project/topics/example-topic].
Created subscription [projects/example-project/subscriptions/example-subscription].
Terminal window
gcloud pubsub topics publish example-topic --message=hello

The message ID differs on every run.

Output
messageIds:
- '14108660267742776'

--auto-ack acknowledges the message as it’s pulled, so it isn’t delivered again.

Terminal window
gcloud pubsub subscriptions pull example-subscription \
--auto-ack --limit=1 --format=json

aGVsbG8= is hello in base64. The ackId and publishTime differ on every run.

Output
[
{
"ackId": "YWNrLWNmYWNmNDFhZjRjODRjMTJiLTE2ZDBhM2Nm",
"ackStatus": "SUCCESS",
"message": {
"data": "aGVsbG8=",
"messageId": "14108660267742776",
"publishTime": "2026-11-02T23:10:54.812Z"
}
}
]

Delete the subscription first, then the topic.

Terminal window
gcloud pubsub subscriptions delete example-subscription --quiet
gcloud pubsub topics delete example-topic --quiet
Output
Deleted subscription [projects/example-project/subscriptions/example-subscription].
Deleted topic [projects/example-project/topics/example-topic].
  • Pub/Sub: what else the emulator supports there, such as push subscriptions, and where it stops. There’s no gRPC, and push endpoints on the public internet aren’t called.
  • Using the emulator: the setup every service shares, and the limits that apply to all of them.
  • All services: what you can test on each Google Cloud service.