Skip to content

Latest commit

 

History

History
57 lines (43 loc) · 2.01 KB

README.md

File metadata and controls

57 lines (43 loc) · 2.01 KB

Latest Stable Version Total Downloads License

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);