You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 17, 2026. It is now read-only.
* Publish the provided message.
*
* @throws {TypeError} If data is not a Buffer object.
* @throws {TypeError} If any value in `attributes` object is not a string.
*
* @param {MessageOptions} message Message object.
* @param {PublishCallback} [callback] Callback function.
* @returns {Promise<PublishResponse>}
*
* @example
....
* @example To publish messages in order (this is still experimental), make sure message ordering is enabled and provide an ordering key
* ```
* const topic = pubsub.topic('ordered-topic', {messageOrdering: true});
* const orderingKey = 'my-key';
*
* topic.publishMessage({data, orderingKey}, callback);
*
* ```
* @example If the callback is omitted, we'll return a Promise.
* ```
* const [messageId] = await topic.publishMessage({data}); <------
* ```
* ```
publishMessage(message: MessageOptions): Promise<[string]>; <-----
Calling const [messageId] = await topic.publishMessage({data});
messageId gets the first character of the id, since publishMessage is returning a string and not an array of strings.