I built BusQue because I found a lack of choice of simple message queues for medium-sized PHP applications.
The name BusQue signifies Command Bus + Message Queue. It was designed to be used in conjunction with Tactician and Redis using either the PHPRedis or Predis clients, along with a serializer such as PHP serialize(), but is open to replacement with alternate adapters.
One key feature I found missing in other queues is the ability to assign a unique ID to a job, allowing the same job to be queued multiple times but have it only execute once after the last insertion.
MGDigitalBusQueBundle provides integration with the Symfony framework.
Install with composer:
composer require mgdigital/busque
Or get the Symfony bundle:
composer require mgdigital/busque-bundle
You'll also need a Redis server to run the queues on.
To use BusQue you first need to instantiate an instance of BusQue\Implementation
with its dependencies. A basic configuration could look something like this:
<?php use MGDigital\BusQue as BusQue; // The preferred client is PHPRedis: $client = new Redis(); $adapter = new BusQue\Redis\PHPRedis\PHPRedisAdapter($client); // A Predis adepter is included, although Predis can have issues when used in long-running processes. // $client = new Predis\Client(); // $adapter = new BusQue\Redis\Predis\PredisAdapter($client); $driver = new BusQue\Redis\RedisDriver($adapter); // The PHP serializer should fit most use cases: $serializer = new BusQue\Serializer\PHPCommandSerializer(); // The MD5 generator creates an ID unique to the serialized command: $idGenerator = new BusQue\IdGenerator\Md5IdGenerator($serializer); $implementation = new BusQue\Implementation( // Puts all commands into the "default" queue: new BusQue\QueueResolver\SimpleQueueResolver('default'), $serializer, $idGenerator, // The Redis driver is used as both the queue and scheduler: $driver, $driver, // Always returns the current time: new BusQue\SystemClock(), // Inject your command bus here: new BusQue\Tactician\CommandBusAdapter($commandBus), // Inject your logger here: new Psr\Log\NullLogger() ); $busQue = new BusQue\BusQue($implementation);