Publish RPC Method

The Publish method is a unary RPC, which means that it sends only one request and receives only one response. It synchronously publishes the batch of events in PublishRequest to an event bus topic. After publishing the event messages, the server sends a response to the client. Use the Publish method if you want to know the status of a publish operation before publishing the next batch of event messages.

The PublishResponse holds a PublishResult for each event published that indicates success or failure of the publish operation. A successful status means that the event was published and is in the event bus. A failed status means that the event failed to publish.

You can retry publishing one or more failed events. If you publish a batch of events, the order of results corresponds to the order of the events in the publish request. You can correlate each successful or failed result with the corresponding event in the publish request.

If you don't want to rely on the order of events published and received, you can use the event id field and correlationKey field of PublishResult. The process is similar to the one described for the PublishStream RPC method. For more information, see PublishStream RPC Method.

For more information about the fields in PublishRequest and PublishResponse, see the Pub/Sub API proto file.