public publishBatch ( array $messages, array $options = [] ) : array | ||
$messages | array | A list of messages. Each message must be in the correct [Message Format](https://cloud.google.com/pubsub/docs/reference/rest/v1/PubsubMessage). If provided, $data will be base64 encoded before being published, unless `$options['encode']` is set to false. (See below for more information.) } |
$options | array | [optional] Configuration Options |
Результат | array | A list of message IDs. |
public function publishBatch(array $messages, array $options = [])
{
foreach ($messages as &$message) {
$message = $this->formatMessage($message);
}
return $this->connection->publishMessage($options + ['topic' => $this->name, 'messages' => $messages]);
}
/** * @expectedException InvalidArgumentException */ public function testPublishMalformedMessage() { $message = ['key' => 'val']; $this->connection->publishMessage(Argument::any()); $topic = new Topic($this->connection->reveal(), 'topic-name', 'project-name'); $topic->publishBatch([$message]); }