https://github.com/wdalmut/queue
Adaptable queue layers
https://github.com/wdalmut/queue
queue queueing rabbitmq rabbitmq-client sqs sqs-interface sqs-queue
Last synced: 4 months ago
JSON representation
Adaptable queue layers
- Host: GitHub
- URL: https://github.com/wdalmut/queue
- Owner: wdalmut
- Created: 2017-01-21T08:50:06.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-01-26T19:16:34.000Z (almost 9 years ago)
- Last Synced: 2025-05-23T11:34:09.608Z (8 months ago)
- Topics: queue, queueing, rabbitmq, rabbitmq-client, sqs, sqs-interface, sqs-queue
- Language: PHP
- Size: 5.86 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Queue
Adaptable queue layers
[](https://travis-ci.org/wdalmut/queue)
[](https://scrutinizer-ci.com/g/wdalmut/queue/?branch=master)
[](https://scrutinizer-ci.com/g/wdalmut/queue/?branch=master)
## Create
```php
$queue = new Queue("queue name", $queueAdapter);
```
[Check also the wiki](https://github.com/wdalmut/queue/wiki)
### Available Adapters
* AWS SQS [https://github.com/wdalmut/queue-sqs](https://github.com/wdalmut/queue-sqs)
* RabbitMQ [https://github.com/wdalmut/queue-rabbitmq](https://github.com/wdalmut/queue-rabbitmq)
* MySQL [https://github.com/wdalmut/queue-mysql](https://github.com/wdalmut/queue-mysql)
* Internal array [https://github.com/wdalmut/queue-array](https://github.com/wdalmut/queue-array)
* [_send an issue/pr to add your adapter here..._](#interface)
## Receive from queue
```php
list($receipt, $message) = $queue->receive();
// receive with options
list($receipt, $message) = $queue->receive(["timeout" => 15*60]);
```
## Send in queue
```php
$queue->send("my message");
// send with options
$queue->send("my message", ["delay" => 20]);
```
## Delete from queue
```php
$queue->delete($receipt);
// delete with options
$queue->delete($receipt, ["delay" => 20]);
```
## Manage different adapters options
Just use functions
```php
$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`
```php
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