Skip to content

Modify async_events.md grammar #364

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 8, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions docs/bundle/async_events.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,24 @@ The consumer, once it receives the message, restores the event and dispatches it

Async listeners benefits:

* The response time lesser. It has to do less work.
* Better fault tolerance. Bugs in async listener does not affect user. Messages will wait till you fix bugs.
* Reduces response time. Work is deferred to consumer processes.
* Better fault tolerance. Bugs in async listener do not affect user. Messages will wait till you fix bugs.
* Better scaling. Add more consumers to meet the load.

_**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)._
_**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)._

## Configuration

I suppose you already [installed the bundle](quick_tour.md#install).
Now, you have to enable `async_events`.
If you do not enable it, events will be processed as before: synchronously.
Symfony events are currently processed synchronously, enabling the async configuration for EnqueueBundle causes tagged listeners to defer action to a consumer asynchronously.
If you already [installed the bundle](quick_tour.md#install), then enable `async_events`.

```yaml
# app/config/config.yml

enqueue:
async_events:
enabled: true
# if you'd like to send send messages onTerminate use spool_producer (it makes response time even lesser):
# if you'd like to send send messages onTerminate use spool_producer (it further reduces response time):
# spool_producer: true
```

Expand Down Expand Up @@ -77,7 +76,7 @@ services:
## Event transformer

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.
You could create a transformer for the given event type. The transformer must implement `Enqueue\AsyncEventDispatcher\EventTransformer` interface.
You can write a transformer for each event type by implementing the `Enqueue\AsyncEventDispatcher\EventTransformer` interface.
Consider the next example. It shows how to send an event that contains Doctrine entity as a subject

```php
Expand Down Expand Up @@ -165,4 +164,4 @@ services:
The `eventName` attribute accepts a regexp. You can do next `eventName: '/foo\..*?/'`.
It uses this transformer for all event with the name beginning with `foo.`

[back to index](../index.md)
[back to index](../index.md)