Skip to content
This repository was archived by the owner on Mar 17, 2026. It is now read-only.

Commit db1f69c

Browse files
docs(sample): regional endpoint in publish ordered message sample (#1140)
1 parent a5ebdcd commit db1f69c

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

samples/publishOrderedMessage.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ async function main(
4747
const {PubSub} = require('@google-cloud/pubsub');
4848

4949
// Creates a client; cache this for further use
50-
const pubSubClient = new PubSub();
50+
const pubSubClient = new PubSub({
51+
// Sending messages to the same region ensures they are received in order
52+
// even when multiple publishers are used.
53+
apiEndpoint: 'us-east1-pubsub.googleapis.com:443',
54+
});
5155

5256
async function publishOrderedMessage() {
5357
// Publishes the message as a string, e.g. "Hello, world!" or JSON.stringify(someObject)

0 commit comments

Comments
 (0)