scienta / php-rsmq-client
A client to publish messages to RSMQ, a nodejs message queue.
Installs: 35 815
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 6
Forks: 1
Open Issues: 0
Requires
- php: ^7.1 || ^8.0
Requires (Dev)
- phpunit/phpunit: ^6.5
Suggests
- ext-redis: PHPRedis extension to communicate with Redis
This package is auto-updated.
Last update: 2024-11-29 05:51:15 UTC
README
php-rsmq-client
A library for queueing RSMQ messages in Redis.
TL;DR
A php implementation of the enqueue-code from RSMQ for adding messages to the queue. Supports realtime PUBLISH of new messages.
Installation
The recommended way to install php-rsmq-client is through Composer. Add the following dependency to your composer.json
{ "require": { "scienta/php-rsmq-client": "~1.0" } }
Alternatively, you can download the source code as a file and extract it.
Usage
Configuration for queues and messages can be more elaborate than specified below, all RSMQ options are supported. The library makes use of a Redis adapter make the usage of other php redis clients possible. Default (used in this example) is the phpredis C extension.
Creating a basic queue
use Scienta\RSMQClient\Config; use Scienta\RSMQClient\Message; use Scienta\RSMQClient\Queue; use Scienta\RSMQClient\Redis\RedisAdapter; //Create a redis connection $redis = new \Redis(); $redis->connect('127.0.0.1', '6379'); //Configure and create/sync a queue $config = new Config('myqueue'); $redisAdapter = new RedisAdapter($redis); $queue = new Queue($config, $redisAdapter); //Create a message $message = new Message('Hello World'); //Send the message $sentId = $queue->sendMessage($message);