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.
The Publish
method doesn’t enforce the presence of required custom event fields in the event payload. If you publish an event without including a required custom field, the publish call succeeds and the received event contains the field with a null value. For system fields, the CreatedDate
and CreatedById
fields are required in the event payload. If you publish an event without these system fields, the call fails.
If you publish a batch of events, the order of results in PublishResponse 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.
You can retry publishing one or more failed events. You can match a publish 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.