Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xp-forge/stomp
STOMP client classes for XP Framework: Publish and subscribe
https://github.com/xp-forge/stomp
php7 php8 stomp xp-framework
Last synced: 3 days ago
JSON representation
STOMP client classes for XP Framework: Publish and subscribe
- Host: GitHub
- URL: https://github.com/xp-forge/stomp
- Owner: xp-forge
- Created: 2012-11-06T17:00:54.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2024-03-24T13:28:35.000Z (6 months ago)
- Last Synced: 2024-04-24T18:55:42.544Z (5 months ago)
- Topics: php7, php8, stomp, xp-framework
- Language: PHP
- Homepage:
- Size: 298 KB
- Stars: 2
- Watchers: 7
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog.md
Awesome Lists containing this project
README
STOMP protocol implementation
===[![Build status on GitHub](https://github.com/xp-framework/ast/workflows/Tests/badge.svg)](https://github.com/xp-framework/ast/actions)
[![XP Framework Module](https://raw.githubusercontent.com/xp-framework/web/master/static/xp-framework-badge.png)](https://github.com/xp-framework/core)
[![BSD Licence](https://raw.githubusercontent.com/xp-framework/web/master/static/licence-bsd.png)](https://github.com/xp-framework/core/blob/master/LICENCE.md)
[![Requires PHP 7.0+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-7_0plus.svg)](http://php.net/)
[![Supports PHP 8.0+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-8_0plus.svg)](http://php.net/)
[![Latest Stable Version](https://poser.pugx.org/xp-forge/stomp/version.png)](https://packagist.org/packages/xp-forge/stomp)About
---
STOMP is a network protocol to talk to message brokers such as [Apache ActiveMQ](http://activemq.apache.org/) or [RabbitMQ](http://rabbitmq.org).The STOMP specification can be found at http://stomp.github.io/.
Examples
---### Producer
A message producer```php
use peer\stomp\{Connection, SendableMessage};$conn= new Connection('stomp://localhost:61613/');
$conn->connect();$conn->getDestination('/queue/producer')->send(
new SendableMessage('Message contents', 'text/plain')
);
```### Consumer
A simple message consumer (subscriber):```php
use peer\stomp\{Connection, Subscription};$conn= new Connection('stomp://localhost:61613/');
$conn->connect();$conn->subscribeTo(new Subscription('/queue/producer', function($message) {
Console::writeLine('---> Received message: ', $message);
$message->ack();
}));$conn->consume();
```### Multi-endpoint failover
A consumer with a broker network may connect to any host when available:```php
use peer\stomp\{Connection, Subscription, Failover};$nodes= ['stomp://one.example.com:61613/', 'stomp://two.example.com:61613/'];
// Connect randomly to one or the other
$conn= new Connection(Failover::using($nodes)->byRandom());
$conn->connect();$conn->subscribeTo(new Subscription('/queue/producer', function($message) {
Console::writeLine('---> Received message: ', $message);
$message->ack();
}));$conn->consume();
```*For more examples, please see the `examples/` directory.*
### The connection URL
The URL specifies the options how and where to connect:* `protocol` should be `stomp` or `stomp+ssl`
* `host` is the hostname to connect
* `port` is the port to connect (default: 61613)
* `user`, `pass` can be given in the URL and will be used for authentication
* Supported parameters:
* `vhost` - virtual host name, since STOMP 1.1 (eg. `?vhost=example.com`)
* `versions` - to specify list of supported versions (eg. `?versions=1.0,1.1`); default is to support 1.0, 1.1