Skip to content

Commit 0f81784

Browse files
committed
update queue docs with basic instal and usage
1 parent 97dc5bd commit 0f81784

File tree

1 file changed

+61
-7
lines changed

1 file changed

+61
-7
lines changed

docs/framework/queues.md

Lines changed: 61 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,74 @@
22

33
> [Message Queue](https://github.com/antidot-framework/message-queue)
44
5+
## Install
6+
57
```bash
68
composer require antidot-fw/message-queue
79
```
810

911
Install a transport for the queues:
1012

11-
* Null Queue
12-
* Filesystem Queue
13-
* DBAL Queue
14-
* Redis Queue
15-
* Beanstalk
16-
* Amazon SQS
17-
13+
* [Null Queue](https://queue.antidotfw.io/#/#null-qeue)
14+
* [Filesystem Queue](https://queue.antidotfw.io/#/#filesystem-qeue)
15+
* [DBAL Queue](https://queue.antidotfw.io/#/#dbal-qeue)
16+
* [Redis Queue](https://queue.antidotfw.io/#/#redis-qeue)
17+
* [Beanstalk](https://queue.antidotfw.io/#/#beanstalk-qeue)
18+
* [Amazon SQS](https://queue.antidotfw.io/#/#amazon-sqs-qeue)
1819

1920
Allow using a job queues out of the box with different queue systems.
2021

2122
[See full documentation](https://queue.antidotfw.io) for transport specific configs.
23+
24+
## Quick start
25+
26+
Once you have installed and configured some transport type following specific config section. You can inject the `Antidot\Queue\Producer` class
27+
inside your classes, for example in a Request Handler.
28+
29+
```php
30+
<?php
31+
32+
declare(strict_types=1);
33+
34+
namespace App\Application\Http\Handler;
35+
36+
use Antidot\Queue\Job;
37+
use Antidot\Queue\Producer;
38+
use Psr\Http\Message\ResponseInterface;
39+
use Psr\Http\Message\ServerRequestInterface;
40+
use Psr\Http\Server\RequestHandlerInterface;
41+
use Laminas\Diactoros\Response\JsonResponse;
42+
43+
class HomePage implements RequestHandlerInterface
44+
{
45+
private Producer $producer;
46+
47+
public function __construct(Producer $producer)
48+
{
49+
$this->producer = $producer;
50+
}
51+
52+
public function handle(ServerRequestInterface $request): ResponseInterface
53+
{
54+
// Send String Job of type "some_message_type" to "default" queue.
55+
$job1 = Job::create('default', 'some_message_type', 'Hello world!!');
56+
$this->producer->enqueue($job1);
57+
58+
// Send Array Job of type "other_message_type" to "other_queue" queue.
59+
$job2 = Job::create('other_queue', 'other_message_type', ['greet' => 'Hello world!!']);
60+
$this->producer->enqueue($job2);
61+
62+
63+
return new JsonResponse([
64+
'docs' => 'https://queue.antidotfw.io',
65+
'Message' => 'Welcome to Antidot Framework Starter'
66+
]);
67+
}
68+
}
69+
```
70+
71+
then start listening a queue:
72+
73+
```bash
74+
bin/console queue:start queue_name
75+
```

0 commit comments

Comments
 (0)