承接 grimkirill/stomp 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

grimkirill/stomp

最新稳定版本:1.1.0

Composer 安装命令:

composer require grimkirill/stomp

包简介

Pure PHP Stomp client. Support protocol v 1.0, 1.1, 1.2. RabbitMQ, Apache ActiveMQ

README 文档

README

Usage

<?php
/**
 * Create connection
 */
$client = new \Stomp\Client(array('tcp://127.0.0.1:61613'), array(
        'login' => 'admin',
        'passcode' => 'password',
        'host' => '/',
        'queue_prefix' => '/queue/',
    ));
        
$client->send('queue_destination', 'hello message');    

$client->subscribe('queue_destination');
while ($message = $client->readMessage()) {
    echo $message->getBody();
    $message->ack();
}

RPC example

server side example

<?php
require_once __DIR__ . '/../tests/Bootstrap.php';

$client = new \Stomp\Client('tcp://127.0.0.1:61613', array('login' => 'admin', 'passcode' => 'password'));

$consumer = new \Stomp\Helper\Consumer($client, '/queue/testing');

$endTime = new \DateTime('+30 second');
$condition = function () use ($endTime) {
    return ((new DateTime()) < $endTime);
};

$consumer->run(function($data, $headers) {
    var_dump($data);
    print_r($headers);
    return date('c');
}, $condition);

client side example

<?php
require_once __DIR__ . '/../tests/Bootstrap.php';

$client = new \Stomp\Client('tcp://127.0.0.1:61613', array('login' => 'admin', 'passcode' => 'password'));

$rpc = new \Stomp\Helper\Rpc($client, '/queue/testing');

var_dump($rpc->call('Ping')); // string(25) "2015-03-13T10:22:27+00:00"

统计信息

  • 总下载量: 592
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-02-07