etopian/rabbitmq-management-api

RabbitMQ 管理HTTP Api的对象封装

2.2.1 2021-10-10 00:35 UTC

This package is auto-updated.

Last update: 2024-10-02 11:53:58 UTC


README

这是一个简单的对象封装,用于PHP 7.1+版本的RabbitMQ 管理HTTP Api

使用PHP-HTTP进行请求。

安装

通过composer安装

$ composer require etopian/rabbitmq-management-api

此外,您需要一个httplug 兼容的客户端

例如,使用Guzzle 7适配器

$ composer require php-http/guzzle7-adapter

基本用法

<?php

use RabbitMq\ManagementApi\Client;

require_once __DIR__ . '/../vendor/autoload.php';

$client = new Client();
$queue = $client->queues()->get('/', 'sample-messages-queue');
$response = $client->exchanges()->publish('/', 'sample-messages', array(
    'properties' => array(),
    'routing_key' => '',
    'payload' => 'This is a test',
    'payload_encoding' => 'string'
));

if ($response['routed']) {
    print 'Message delivered';
}

许可

php-rabbitmq-management-api遵循MIT许可 - 详细信息请参阅LICENSE文件

致谢

结构来自KnpLabs php-github-api

Rabbit的优秀消息队列