snailweb / kubemq
KubeMQ 的 PHP 客户端
1.0.1
2020-03-11 16:07 UTC
This package is auto-updated.
Last update: 2024-09-12 02:30:28 UTC
README
使用 REST API 的 KubeMQ PHP 客户端
安装
composer require snailweb/kubemq
要求
- PHP 7.1+
- CURL
功能
- 队列
峰值- 发送
批量发送- 接收
确认所有消息
发布/订阅远程过程调用(RPC)
队列
发送消息
$queue = new \Snailweb\KubeMQ\Queue('kubemq-host', 9090, 'ClientA', 'Channel'); $message = new \Snailweb\KubeMQ\Message( 'metadata', // metadata (could be anything: int, string, array, object ...) ['field1' => 4, 'field2' => 'info'] // body (could be anything: int, string, array, object ...) ); // Optional settings here $message->setExpirationSeconds(5) ->setDelaySeconds(5) ->setMaxReceiveCount(10) ->setMaxReceiveQueue('queue-name'); try { $queue->send($message); } catch(Exception $exception) { var_dump($exception); }
接收消息
$queue = new \Snailweb\KubeMQ\Queue('kubemq-host', 9090, 'ClientB', 'Channel', 32, // optional default max receive msg for this client 1); // optional default waiting time for this client try { $messages = $queue->receive(32, 1); // optional: we can override defaults of this client if(!empty($messages)) { var_dump($messages); } else { echo "no messages\n"; } } catch(Exception $exception) { var_dump($exception); }