Giter VIP home page Giter VIP logo

stomp's Introduction

Stomp for PHP

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"

stomp's People

Contributors

grimkirill avatar

Stargazers

KK avatar Cees-Jan Kiewiet avatar Arnaud Ligny avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.