You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/bundle/message_processor.md
+78-2Lines changed: 78 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,7 @@ Here we just show how to register a message processor service to enqueue. Let's
5
5
6
6
*[Container tag](#container-tag)
7
7
*[Topic subscriber](#topic-subscriber)
8
+
*[Command subscriber](#command-subscriber)
8
9
9
10
# Container tag
10
11
@@ -27,8 +28,8 @@ The tag has some additional options:
27
28
28
29
# Topic subscriber
29
30
30
-
There is a `TopicSubscriber` interface (like [EventSubscriberInterface](https://github.com/symfony/symfony/blob/master/src/Symfony/Component/EventDispatcher/EventSubscriberInterface.php)).
31
-
It allows to keep subscription login and process logic closer to each other.
31
+
There is a `TopicSubscriberInterface` interface (like [EventSubscriberInterface](https://github.com/symfony/symfony/blob/master/src/Symfony/Component/EventDispatcher/EventSubscriberInterface.php)).
32
+
It is handy to subscribe on event messages. It allows to keep subscription login and process logic closer to each other.
32
33
33
34
```php
34
35
<?php
@@ -67,6 +68,81 @@ class SayHelloProcessor implements PsrProcessor, TopicSubscriberInterface
67
68
68
69
In the container you can just add the tag `enqueue.client.message_processor` and omit any other options:
69
70
71
+
```yaml
72
+
# src/AppBundle/Resources/services.yml
73
+
74
+
services:
75
+
app.async.say_hello_processor:
76
+
class: 'AppBundle\Async\SayHelloProcessor'
77
+
tags:
78
+
- { name: 'enqueue.client.processor'}
79
+
80
+
```
81
+
82
+
# Command subscriber
83
+
84
+
There is a `CommandSubscriberInterface` interface which allows to register a command handlers.
85
+
If you send a message using ProducerV2::sendCommand('aCommandName') method it will come to this processor.
86
+
87
+
```php
88
+
<?php
89
+
namespace AppBundle\Async;
90
+
91
+
use Enqueue\Client\CommandSubscriberInterface;
92
+
use Enqueue\Psr\PsrProcessor;
93
+
94
+
class SayHelloProcessor implements PsrProcessor, CommandSubscriberInterface
95
+
{
96
+
public static function getSubscribedCommand()
97
+
{
98
+
return 'aCommandName';
99
+
}
100
+
}
101
+
```
102
+
103
+
On the command subscriber you can also define additional settings such as queue and processor name:
104
+
105
+
```php
106
+
<?php
107
+
use Enqueue\Client\CommandSubscriberInterface;
108
+
use Enqueue\Psr\PsrProcessor;
109
+
110
+
class SayHelloProcessor implements PsrProcessor, CommandSubscriberInterface
0 commit comments