shyam-achuthan/google-cloud
Composer 安装命令:
composer require shyam-achuthan/google-cloud
包简介
A library for easy access of google cloud platform - PubSub ( Alternative to Amazon SQS )
README 文档
README
An easy to use platform for google pubsub on php
composer require shyam-achuthan/google-cloud
Initializing the library
$projectId = "<your-google-project-id>";
$key_file_location = "<path-to-service-account-json-credentials";
$pubsub = new \GoogleCloud\Pubsub($projectId,$key_file_location);
$pubsub->setTopic("<your-message-topic>");
$pubsub->setSubscription("<your-pull-subscription-name>");
Sending a message to the queue
$data = ["name"=>"Shyam",'email'=>"shyam@shyamachuthan.com" ]; // string key value pair data to pass to the queue receiver
$message = "SEND_USER_WELCOME_EMAIL"; // any text message here am using this string to differentiate the actions on the receiver side
$response = $pubsub->sendMessage($message,$data);
$resp = $response;
Receiving queue messages
$resp = $pubsub->receiveMessages();
will return Array of message objects which has three attributes - message_title - [String] the message passed to send message while sending - data - [Array] array of data ( key value pair as passed in sending message ) - handle - [String] unique identifier of the message, the acknoledgement-id which is used to delete the message
Delete a message
$response = $pubsub->deleteMessage($message->handle);
Receive message do execution and delete message
$resp = $pubsub->receiveMessages();
foreach($resp as $message){
// Do what ever executin needed with $message->message_title, $message->data
$pubsub->deleteMessage($message->handle);
}
Delete multiple messages together
$pubsub->deleteMessage($handles); // where handles is array of handle/acknowledgement-ids
统计信息
- 总下载量: 24
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-08-18