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/async_events.md
+10-11
Original file line number
Diff line number
Diff line change
@@ -7,25 +7,24 @@ The consumer, once it receives the message, restores the event and dispatches it
7
7
8
8
Async listeners benefits:
9
9
10
-
*The response time lesser. It has to do less work.
11
-
* Better fault tolerance. Bugs in async listener does not affect user. Messages will wait till you fix bugs.
10
+
*Reduces response time. Work is deferred to consumer processes.
11
+
* Better fault tolerance. Bugs in async listener do not affect user. Messages will wait till you fix bugs.
12
12
* Better scaling. Add more consumers to meet the load.
13
13
14
-
_**Note**: The php serializer transformer (the default one) does not work on Symfony prior 3.0. The event contains eventDispatcher and therefor could not be serialized. You have to register a transformer for every async event. Read the [event transformer](#event-transformer)._
14
+
_**Note**: Prior to Symfony 3.0, events contain `eventDispatcher` and the default php serializer transformer is unable to serialize the object. A transformer should be registered for every async event. Read the [event transformer](#event-transformer)._
15
15
16
16
## Configuration
17
17
18
-
I suppose you already [installed the bundle](quick_tour.md#install).
19
-
Now, you have to enable `async_events`.
20
-
If you do not enable it, events will be processed as before: synchronously.
18
+
Symfony events are currently processed synchronously, enabling the async configuration for EnqueueBundle causes tagged listeners to defer action to a consumer asynchronously.
19
+
If you already [installed the bundle](quick_tour.md#install), then enable `async_events`.
21
20
22
21
```yaml
23
22
# app/config/config.yml
24
23
25
24
enqueue:
26
25
async_events:
27
26
enabled: true
28
-
# if you'd like to send send messages onTerminate use spool_producer (it makes response time even lesser):
27
+
# if you'd like to send send messages onTerminate use spool_producer (it further reduces response time):
29
28
# spool_producer: true
30
29
```
31
30
@@ -77,7 +76,7 @@ services:
77
76
## Event transformer
78
77
79
78
The bundle uses [php serializer](https://github.com/php-enqueue/enqueue-dev/blob/master/pkg/enqueue-bundle/Events/PhpSerializerEventTransformer.php) transformer by default to pass events through MQ.
80
-
You could create a transformer for the given event type. The transformer must implement `Enqueue\AsyncEventDispatcher\EventTransformer` interface.
79
+
You can write a transformer for each event type by implementing the `Enqueue\AsyncEventDispatcher\EventTransformer` interface.
81
80
Consider the next example. It shows how to send an event that contains Doctrine entity as a subject
82
81
83
82
```php
@@ -113,7 +112,7 @@ class FooEventTransformer implements EventTransformer
113
112
public function toMessage($eventName, Event $event = null)
0 commit comments