-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
31 lines (27 loc) · 815 Bytes
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
require __DIR__ . '/vendor/autoload.php';
use Google\Cloud\PubSub\MessageBuilder;
use Google\Cloud\PubSub\PubSubClient;
/**
* Publishes a message for a Pub/Sub topic.
*
* @param string $projectId The Google project ID.
* @param string $topicName The Pub/Sub topic name.
* @param string $message The message to publish.
*/
function publish_message($projectId, $topicName, $message)
{
$pubsub = new PubSubClient([
'projectId' => $projectId,
]);
$topic = $pubsub->topic($topicName);
$topic->publish((new MessageBuilder)->setData($message)->build());
print('Message published: '.$message . PHP_EOL);
}
for($i=0;$i<=10;$i++){
publish_message('incentro-spain-projects', 'poc-oscar-multiclient', 'test '.$i);
echo "<br>";
flush();
ob_flush();
sleep(1);
}