STOMP bindings for ReactPHP.

Related tags

Queue stomp
Overview

React/STOMP

STOMP bindings for React.

STOMP is a messaging protocol. It is supported by most message queue brokers, such as RabbitMQ, Apollo and many others.

A message queue is used for asynchronous inter-process communication. This can be useful for workers, general long-running tasks, or communication between long-running daemons.

Build Status Code Climate

Install

The recommended way to install react/stomp is through composer.

{
    "require": {
        "react/stomp": "0.1.*"
    }
}

Example

You can interact with a STOMP server by using the React\Stomp\Client.

<?php

$loop = React\EventLoop\Factory::create();
$factory = new React\Stomp\Factory($loop);
$client = $factory->createClient(array('vhost' => '/', 'login' => 'guest', 'passcode' => 'guest'));

$client
    ->connect()
    ->then(function ($client) use ($loop) {
        $client->subscribe('/topic/foo', function ($frame) {
            echo "Message received: {$frame->body}\n";
        });

        $loop->addPeriodicTimer(1, function () use ($client) {
            $client->send('/topic/foo', 'le message');
        });
    });

$loop->run();

Options

  • host: Host to connect to, defaults to 127.0.0.1.
  • port: Port to connect to, defaults to 61613 (rabbitmq's stomp plugin).
  • vhost: Virtual host, defaults to /.
  • login: Login user name, defaults to guest.
  • passcode: Login passcode, defaults to guest.

Acknowledgement

When subscribing with the subscribe method, messages are considered acknowledged as soon as they are sent by the server (ack header is set to 'auto').

You can subscribe with a manual acknowledgement by using subscribeWithAck (see SUBSCRIBE in the STOMP spec for available ack mode values).

You will get a React\Stomp\AckResolver as second argument of the callback to acknowledge or not the message :

$client->subscribeWithAck('/topic/foo', 'client', function ($frame, $ackResolver) {
    if ($problem) {
        $ackResolver->nack();
    } else {
        $ackResolver->ack();
    }
});

Todo

  • Support nul bytes in frame body
  • Heart-beating
  • Consuming ACKs
  • Transactions
  • Streaming frame bodies (using stream API)

Tests

To run the test suite, you need PHPUnit.

$ phpunit

License

MIT, see LICENSE.

Resources

Comments
  • Capture and emit input end event

    Capture and emit input end event

    This is another PR for reactphp/stomp#24. It forwards the end event through the InputStream class and through the Client, similar to how errors are handled.

    I need to handle server-side restarts, and I can't detect a disconnection without this fix.

    Thank you!

    Jason

    opened by jasonrsmith 7
  • Update to more recent values

    Update to more recent values

    Currenlty this MR does the following

    • [x] Switch to PSR-4
    • [x] Update the tested PHP versions
    • [x] Make sure tests succeed
    • [x] Add a docker container to test the things Travis would normally do (it's not completly the same tho :()
    • [x] Make sure it works against a recent version of React
    • [x] Add tests for ActiveMQ
    • [x] squashed commits

    Currently ActiveMQ tests are run without auth tests because Ubuntu ActiveMQ 5.6 for some reason doesn't allow plugins

    opened by the-eater 4
  • Throw a ConnectionException if the connection ends

    Throw a ConnectionException if the connection ends

    This is a fix for #24

    I think we should move the stream_socket_client call when React\Stomp\Client::connect is called. We could provide automatic reconnection that way.

    opened by romainneutron 3
  • Add Apollo and ActiveMQ compatibility

    Add Apollo and ActiveMQ compatibility

    ActiveMQ frames might start with a new-line caracter, producing an offset error in the parser.

    Example of ActiveMQ frame :

    \nMESSAGE\ncontent-type:text/plain\ndestination:/topic/foo\ntimestamp:1356608654862\ncontent-length:10\npriority:4\n\nle message
    
    opened by romainneutron 3
  • Subscribing to non-existing topic causes parser error

    Subscribing to non-existing topic causes parser error

    Specifically in line 36 of \React\Stomp\Protocol\Parser.php

    <?php
    /*** snip ***/
    public function parseFrameData($data)
    {
            $frame = new Frame();
    
            list($head, $body) = explode("\n\n", $data, 2);
    

    I don't know the protocol well enough to implement a proper fix for compensating when $data is empty.

    opened by mrferos 2
  • Client creation failure does not trigger the promise rejection

    Client creation failure does not trigger the promise rejection

    In the following code, the exit('error'); is never triggered

    The bug occurs whenever a process is listening to the port or not.

    $loop = React\EventLoop\Factory::create();
    $factory = new React\Stomp\Factory($loop);
    $client = $factory->createClient(array('port' =>80));
    
    $client
        ->connect()
        ->then(
             function () {},
             function () { exit("error"); }
        );
    
    $loop->run();
    
    opened by romainneutron 1
  • reactphp ^0.7 || ^1.0 || ^1.1 compatibility

    reactphp ^0.7 || ^1.0 || ^1.1 compatibility

    • Bump react deps to 1.1.* (@phiamo)
    • combined the in 0.6.0 existing ReadableStream and WritableStream into the now also final InputStream and OutputStream classes
    • adapted the cancelTimer API change in Client

    All Unit tests are green!

    opened by phiamo 2
  • Upgrade `react/socket` to ^1.1

    Upgrade `react/socket` to ^1.1

    I had a dependency clash for react/socket ^1.1.

    That version has all classes set as final, so I had to put a bit of effort to learn react/socket and get this package working with it. Hopefully, you're happy with the upgrade. Otherwise, I am open to feedback to get this merged.

    Notes:

    • I don't think this is a breaking change. I didn't need to update the functional tests.
    • I added a connection-status event. It was useful information for me to print in my logs.
    maintenance 
    opened by adrianb93 1
  • add TLS support

    add TLS support

    This adds the ability to connect to TLS-protected queue brokers, via the 'protocol' option. Update affected unit tests, add functional test (verified against activemq v5.15.0). Also document how to run the functional tests

    new feature help wanted 
    opened by brettmc 5
  • Heartbeat implementation

    Heartbeat implementation

    I'm curious about something. While looking at the network of this repository I've come across the branch of @capablue. They implemented the heartbeat functionality I was looking for and they apparently think it is stable enough because they've added a tag. After some testing locally this does suit our needs.

    What I find most interesting is that I can't find any pull request or issues created by Capablue in this repository. Unfortunately the organisation doesn't have any public members so I'm unable to search more in depth and contact people. Is this something worth looking into? Perhaps even forking that repository and create a pull request myself?

    I would like to continue to use the official stomp repository instead of a fork. Any thoughts, @igorw?

    Link to repository: https://github.com/capablue/stomp

    opened by RolfBabijn 2
Owner
Friends of ReactPHP
Friends of @ReactPHP
Friends of ReactPHP
Laravel Enqueue message queue extension. Supports AMQP, Amazon SQS, Kafka, Google PubSub, Redis, STOMP, Gearman, Beanstalk and others

Laravel queue package You can use all transports built on top of queue-interop including all supported by Enqueue. It also supports extended AMQP feat

Enqueue 204 Dec 22, 2022
Performant pure-PHP AMQP (RabbitMQ) sync/async (ReactPHP) library

BunnyPHP Performant pure-PHP AMQP (RabbitMQ) sync/async (ReactPHP) library Requirements BunnyPHP requires PHP 7.1 and newer. Installation Add as Compo

Jakub Kulhan 641 Dec 29, 2022
PHP bindings for Tarantool Queue.

Tarantool Queue Tarantool is a NoSQL database running in a Lua application server. It integrates Lua modules, called LuaRocks. This package provides P

Tarantool PHP 62 Sep 28, 2022
Laravel Enqueue message queue extension. Supports AMQP, Amazon SQS, Kafka, Google PubSub, Redis, STOMP, Gearman, Beanstalk and others

Laravel queue package You can use all transports built on top of queue-interop including all supported by Enqueue. It also supports extended AMQP feat

Enqueue 204 Dec 22, 2022
ReactPHP Shell, based on the Symfony Console component.

Pecan Event-driven, non-blocking shell for ReactPHP. Pecan (/pɪˈkɑːn/) provides a non-blocking alternative to the shell provided in the Symfony Consol

Michael Crumm 43 Sep 4, 2022
PHPUnit assertions for testing ReactPHP promises

ReactPHP Promises Testing A library that provides a set of convenient assertions for testing ReactPHP promises. Under the hood uses clue/php-block-rea

Sergey Zhuk 30 Dec 8, 2022
Performant pure-PHP AMQP (RabbitMQ) sync/async (ReactPHP) library

BunnyPHP Performant pure-PHP AMQP (RabbitMQ) sync/async (ReactPHP) library Requirements BunnyPHP requires PHP 7.1 and newer. Installation Add as Compo

Jakub Kulhan 641 Dec 29, 2022
Cronlike scheduler running inside a ReactPHP Event Loop

Cronlike scheduler running inside a ReactPHP Event Loop Install To install via Composer, use the command below, it will automatically detect the lates

Cees-Jan Kiewiet 35 Jul 12, 2022
Spike is a fast reverse proxy built on top of ReactPHP that helps to expose your local services to the internet.

Spike is a fast reverse proxy built on top of ReactPHP that helps to expose your local services to the internet. 简体中文 Installation Install via compose

Tao 649 Dec 26, 2022
Async Redis client implementation, built on top of ReactPHP.

clue/reactphp-redis Async Redis client implementation, built on top of ReactPHP. Redis is an open source, advanced, in-memory key-value database. It o

Christian Lück 240 Dec 20, 2022
This library brought ReactPHP and QueryList together

ReactPHP QueryList This library brought ReactPHP and QueryList together. Installation composer require ahmard/reactphp-querylist Usage Playing with Q

Ahmad Mustapha 5 Nov 19, 2021
Simple and universal connection pool for ReactPHP applications.

szado/reactphp-connection-pool Async and flexible pool for any type of connections built on top of ReactPHP. Connection pooling allows you to easily m

shado 2 Apr 30, 2022
Xr - Lightweight debug server utility built on ReactPHP.

XR ?? Subscribe to the newsletter to don't miss any update regarding Chevere. XR is a dump server utility built on top of ReactPHP. Features ✨ Dump si

Chevere 195 Dec 17, 2022
Event-driven, streaming HTTP client and server implementation for ReactPHP

HTTP Event-driven, streaming HTTP client and server implementation for ReactPHP. This HTTP library provides re-usable implementations for an HTTP clie

ReactPHP 640 Dec 29, 2022
Async MySQL database client for ReactPHP.

MySQL Async MySQL database client for ReactPHP. This is a MySQL database driver for ReactPHP. It implements the MySQL protocol and allows you to acces

Friends of ReactPHP 302 Dec 11, 2022
Async HTTP proxy connector, tunnel any TCP/IP-based protocol through an HTTP CONNECT proxy server, built on top of ReactPHP.

clue/reactphp-http-proxy Async HTTP proxy connector, tunnel any TCP/IP-based protocol through an HTTP CONNECT proxy server, built on top of ReactPHP.

Christian Lück 43 Dec 25, 2022
ReactPHP HttpClient Adapter for Guzzle6, for Guzzle5 check ReactGuzzleRing

react-guzzle-psr7 ReactPHP HttpClient Adapter for Guzzle6, for Guzzle5 check ReactGuzzleRing Installation To install via Composer, use the command bel

Cees-Jan Kiewiet 69 Dec 8, 2022
Lightweight library that eases using components built for ReactPHP in a traditional, blocking environment.

clue/reactphp-block Lightweight library that eases integrating async components built for ReactPHP in a traditional, blocking environment. ReactPHP pr

Christian Lück 154 Sep 10, 2022
Simple, async SOAP webservice client, built on top of ReactPHP.

clue/reactphp-soap Simple, async SOAP web service client library, built on top of ReactPHP. Most notably, SOAP is often used for invoking Remote proce

Christian Lück 62 Jul 5, 2022
DNS over HTTPS executor for ReactPHP/dns

DNS over HTTPS client for ReactPHP Resolve DNS queries over HTTPS, provides secure DNS resolution over untrusted or shared networks (eg Serverless dep

James Lucas 6 Oct 7, 2022