Reference documentation and code samples for the Cloud PubSub Client class BatchPublisher.
Publishes messages to Google Cloud Pub\Sub with background batching.
Example:
use Google\Cloud\PubSub\PubSubClient;
$pubsub = new PubSubClient();
$batchPublisher = $pubsub->topic('my_topic')
->batchPublisher();
$batchPublisher->publish([
'data' => 'An important message.'
]);
Methods
__construct
| Parameters | |
|---|---|
| Name | Description |
topicName |
string
The topic name. |
options |
array
[optional] Please see {@see \Google\Cloud\PubSub\Google\Cloud\PubSub\Topic::batchPublisher()} for configuration details. |
publish
Send messages to a batch queue.
Example:
$batchPublisher->publish([
'data' => 'An important message.'
]);
| Parameter | |
|---|---|
| Name | Description |
message |
Google\Cloud\PubSub\Message|array
An instance of {@see \Google\Cloud\PubSub\Google\Cloud\PubSub\Message}, or an array in the correct Message Format. |
| Returns | |
|---|---|
| Type | Description |
bool |
|
Constants
ID_TEMPLATE
Value: 'pubsub-topic-%s'