-
Notifications
You must be signed in to change notification settings - Fork 5
Home
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.
- Magento
>= 2.3.6 - PHP
>= 7.0 - RabbitMQ (Recommended) otherwise see configuring to use DB
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
bin/magento module:enable Aligent_AsyncEventsbin/magento setup:upgrade
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.
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