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.
Before you start
Section titled “Before you start”- 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, pluspython3to 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.
Point your client at the emulator
Section titled “Point your client at the emulator”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.
export VERA_ENDPOINT="http://localhost:8081"export CLOUDSDK_AUTH_DISABLE_CREDENTIALS=trueexport CLOUDSDK_CORE_PROJECT=example-projectexport 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/"Every request goes to the project’s Pub/Sub path, with no Authorization header:
export VERA_ENDPOINT="http://localhost:8081"BASE="$VERA_ENDPOINT/_gcp/pubsub/v1/projects/example-project"Create a topic and a subscription
Section titled “Create a topic and a subscription”A subscription receives the messages published to its topic, so create the topic first.
gcloud pubsub topics create example-topic --quietgcloud pubsub subscriptions create example-subscription --topic=example-topic --quietCreated topic [projects/example-project/topics/example-topic].Created subscription [projects/example-project/subscriptions/example-subscription].curl -X PUT "$BASE/topics/example-topic" \ -H "Content-Type: application/json" -d '{}'{ "name": "projects/example-project/topics/example-topic"}curl -X PUT "$BASE/subscriptions/example-subscription" \ -H "Content-Type: application/json" \ -d '{"topic":"projects/example-project/topics/example-topic"}'The subscription comes back with its defaults:
{ "ackDeadlineSeconds": 10, "expirationPolicy": { "ttl": "2678400s" }, "messageRetentionDuration": "604800s", "name": "projects/example-project/subscriptions/example-subscription", "pushConfig": {}, "state": "ACTIVE", "topic": "projects/example-project/topics/example-topic"}Publish a message
Section titled “Publish a message”gcloud pubsub topics publish example-topic --message=helloThe message ID differs on every run.
messageIds:- '14108660267742776'Message data is base64: aGVsbG8= is hello.
curl -X POST "$BASE/topics/example-topic:publish" \ -H "Content-Type: application/json" \ -d '{"messages":[{"data":"aGVsbG8="}]}'The message ID differs on every run.
{ "messageIds": ["14108660267742776"]}Pull the message
Section titled “Pull the message”--auto-ack acknowledges the message as it’s pulled, so it isn’t delivered again.
gcloud pubsub subscriptions pull example-subscription \ --auto-ack --limit=1 --format=jsonaGVsbG8= is hello in base64. The ackId and publishTime differ on every run.
[ { "ackId": "YWNrLWNmYWNmNDFhZjRjODRjMTJiLTE2ZDBhM2Nm", "ackStatus": "SUCCESS", "message": { "data": "aGVsbG8=", "messageId": "14108660267742776", "publishTime": "2026-11-02T23:10:54.812Z" } }]Pull the message and save the response to pull.json:
curl -X POST "$BASE/subscriptions/example-subscription:pull" \ -H "Content-Type: application/json" -d '{"maxMessages":1}' -o pull.jsoncat pull.jsonThe ackId and publishTime differ on every run.
{ "receivedMessages": [ { "ackId": "YWNrLTEyYTA2NTdmNmZiYTQzODdhLTE2ZDBhM2Nm", "message": { "data": "aGVsbG8=", "messageId": "14108660267742776", "publishTime": "2026-11-02T23:10:56.202Z" } } ]}Then acknowledge it, so it isn’t delivered again. Do it within the subscription’s 10-second acknowledgment deadline: in testing of Vera 1.2.0 preview, a message left unacknowledged past its deadline was returned by a later pull, with a new ackId. The first line copies the ackId from pull.json into ack.json. The emulator answers {}.
python3 -c 'import json; p=json.load(open("pull.json")); json.dump({"ackIds":[x["ackId"] for x in p["receivedMessages"]]},open("ack.json","w"))'curl -X POST "$BASE/subscriptions/example-subscription:acknowledge" \ -H "Content-Type: application/json" -d @ack.jsonClean up
Section titled “Clean up”Delete the subscription first, then the topic.
gcloud pubsub subscriptions delete example-subscription --quietgcloud pubsub topics delete example-topic --quietDeleted subscription [projects/example-project/subscriptions/example-subscription].Deleted topic [projects/example-project/topics/example-topic].Each request answers {}. Then remove the two files the pull and the acknowledgment used.
curl -X DELETE "$BASE/subscriptions/example-subscription"curl -X DELETE "$BASE/topics/example-topic"rm pull.json ack.jsonNext steps
Section titled “Next steps”- 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.