Skip to content
Gowri edited this page Mar 24, 2023 · 19 revisions

Introduction

Async Events allows you to define and process events asynchronously. A common use case for this is to create webhooks (publishers) or relaying information into another system in real time.

Requirements

  1. Magento >= 2.3.6
  2. PHP >= 7.0
  3. RabbitMQ (Recommended) otherwise see configuring to use DB

Getting Started

It is recommended that you install this module via composer.

composer require aligent/async-events to require it as a dependency via composer

If you are using RabbitMQ, you need to make sure that a config for amqp is present in your env.php

Enable the module with

  1. bin/magento module:enable Aligent_AsyncEvents
  2. bin/magento setup:upgrade

NotifierFactory Setup

A simple factory and a HTTP notifier is provided as a reference.

<!-- Aligent\AsyncEvents\etc\di.xml -->

<preference for="Aligent\AsyncEvents\Service\AsyncEvent\NotifierFactoryInterface"
            type="Aligent\AsyncEvents\Service\AsyncEvent\NotifierFactory" />

<type name="Aligent\AsyncEvents\Service\AsyncEvent\NotifierFactory">
    <arguments>
        <argument name="notifierClasses" xsi:type="array">
            <item name="http" xsi:type="object">Aligent\AsyncEvent\Service\AsyncEvent\HttpNotifier</item>
        </argument>
    </arguments>
</type>

Note that in this setup, the name of the notifier (http in this case) is what you'll be using to say which notifier a subscription should use. if you had multiple different notifiers, you have to configure them here.

Consumers

The event.trigger.consumer and the event.retry.consumer should be running in order to pick events from the queue and process them.

i.e:

$ bin/magento queue:consumer:start event.trigger.consumer
$ bin/magento queue:consumer:start event.retry.consumer
Clone this wiki locally