-
Notifications
You must be signed in to change notification settings - Fork 4
I. How Async Events Work
Asynchronous events are defined in an async_events.xml
. This is similar to defining regular events with events.xml
. An asynchronous event can have many subscribers which listen to it and get notified when the event is dispatched.
The above image describes the logical flow of a single asynchronous event dispatched to three subscribers. The event is dispatched from Magento and placed on a queue. Then it is picked up by a consumer that is responsible to dispatch the notifications to the subscribers in a way intended for them.
For example, subscriber 1 might want to be notified via REST, subscriber 2 via SOAP and subscriber 3 via gRPC.
<async_event name="sales.order.created">
<service class="Magento\Sales\Api\OrderRepositoryInterface" method="get"/>
</async_event>
The above code defines an async_event
named sales.order.created
and when it is dispatched to its subscribers it will have the payload which is the return value of Magento\Sales\Api\OrderRepositoryInterface::get