Skip to content

II. Getting Started

Gowri edited this page Dec 7, 2021 · 20 revisions

Key Concepts

  1. Async Events - are events that are dispatched from Magento when they are triggered
  2. Subscribers - is something that listens to one or several async events.

Defining an Async Event

Async events are defined in etc/async_events.xml. The definition only provides an acknowledgement to Magento that such an async event exist. It has to be dispatched by you at a place you find suitable.

    <async_event name="sales.order.created">
        <service class="Magento\Sales\Api\OrderRepositoryInterface" method="get"/>
    </async_event>
  1. async_event
    • name - A unique name given to the asynchronous event
  2. service
    • class - The class or interface that defines the handler.
    • method - The method which is executed and the return value is published to subscribers.

Dispatching Async Events

Clone this wiki locally