corley / queue
1.0.0
2017-01-21 09:22 UTC
Requires (Dev)
- phpunit/phpunit: ~4.0
This package is not auto-updated.
Last update: 2024-10-26 20:09:54 UTC
README
Adaptable queue layers
Create
$queue = new Queue("queue name", $queueAdapter);
Available Adapters
- AWS SQS https://github.com/wdalmut/queue-sqs
- RabbitMQ https://github.com/wdalmut/queue-rabbitmq
- MySQL https://github.com/wdalmut/queue-mysql
- Internal array https://github.com/wdalmut/queue-array
- send an issue/pr to add your adapter here...
Receive from queue
list($receipt, $message) = $queue->receive(); // receive with options list($receipt, $message) = $queue->receive(["timeout" => 15*60]);
Send in queue
$queue->send("my message"); // send with options $queue->send("my message", ["delay" => 20]);
Delete from queue
$queue->delete($receipt); // delete with options $queue->delete($receipt, ["delay" => 20]);
Manage different adapters options
Just use functions
$queue = new Queue("https://sqs.amazon.com/39857/urs", $sqsAdapter); $queue->send("message", toSQS(["delay" => 20])); function toSQS(array options = []) { $opts = []; if (array_key_exists("delay", $options)) { $opts["DelaySeconds"] = $options["delay"]; } return $opts; }
Queue Interface (for adapters)
You have to implement 3 methods from Corley\Queue\QueueInterface
public function send($queueName, $message, array $options); public function receive($queueName, array $options); public function delete($queueName, $receipt, array $options);
Tips on return values (receive
message)
As you can see the return value
- The send operation should return the queue send operation status
- The receive MUST return an array where the first parameter is the message receipt that is need for the remove operation
- The delete operation should return the queue delete operation status