Configure Adobe Commerce
After you have created an App Builder project and install the eventing modules, you must download several files from the App Builder project and configure eventing in the Commerce admin.
Configure the Adobe I/O connection
You must configure Commerce to communicate with your project. Configuration includes copying and pasting the contents of the workspace configuration file that you downloaded from the Adobe Developer Console. If you decided to use JSON Web Tokens (JWT) as your server-to server authentication method, you must also upload a private key.
In the Commerce Admin, navigate to Stores > Settings > Configuration > Adobe Services > Adobe I/O Events > General configuration. The following screen displays.
Select the server-to-server authorization method you implemented from the Adobe I/O Authorization Type menu. Adobe recommends using OAuth. JWT has been deprecated.
(JWT only) Copy and paste the contents of your
private.key
file into the Service Account Private Key field. Use the following command to copy the contents.Copied to your clipboardcat config/private.key | pbcopySee Service Account (JWT) Authentication for more information about the
private.key
file.Copy the contents of the
<workspace-name>.json
file into the Adobe I/O Workspace Configuration field.Enter a unique identifier in the Adobe Commerce Instance ID field. This value must contain English alphanumeric characters, underscores (_), and hyphens (-) only.
Click Save Config, but do not leave the page. The next section creates an event provider, which is necessary to complete the configuration.
Create an event provider and complete the Commerce configuration
You cannot create an event provider until you have configured and saved a workspace file and instance ID values. If you are using JWT for server-to-server authentication, you must also have previously specified the private key.
Run the following command to create an event provider:
Copied to your clipboardbin/magento events:create-event-provider --label "<unique_provider_label>" --description "<provider description>"For example:
Copied to your clipboardbin/magento events:create-event-provider --label "My_server_provider" --description "Provides out-of-process extensibility for Adobe Commerce"Note: The label can contain English alphanumeric characters and underscores (_) only. The first character must be a letter.
The command displays a message similar to the following:
Copied to your clipboardNo event provider found, a new event provider will be createdA new event provider has been created with ID 63a1f8fe-e911-45a4-9d3fCopy the ID returned in the command output into the Adobe I/O Event Provider ID field in the Admin.
Enable Commerce Eventing by setting Enabled to
Yes
.Note: You must enable cron so that Commerce can send events to the endpoint.
Enter the merchant's company name in the Merchant ID field. You must use alphanumeric and underscores only.
In the Environment ID field, enter a temporary name for your workspaces while you are in development mode. When you are ready for production, change this value to a permanent value, such as Production.
(Optional) By default, if an error occurs when Adobe Commerce attempts to send an event to Adobe I/O, Commerce retries a maximum of seven times. To change this value, uncheck the Use system value checkbox and set a new value in the Maximum retries to send events field.
(Optional) By default, Adobe Commerce runs a cron job (clean_event_data) every 24 hours that deletes event data that is three days old. To change the number of days to retain event data, uncheck the Use system value checkbox and set a new value in the Event retention time (in days) field.
Click Save Config.
After you have completely configured and saved your Adobe I/O event connection and your event provider, you can click the Send Test Event button to determine the status of the connection. The response displays beneath the button.
Subscribe and register events
You must define which Commerce events to subscribe to, then register them in the project.
Commerce provides two sources for events: observers and plugins. You must specify the source as part of the event name. See Subscribe to a Commerce event for details about the syntax of the events:subscribe
command.
If you don't have a module ready for integration with Adobe I/O Events, or you don't know exactly which events to register at this point, use the
events:subscribe
command to subscribe to some sample events, as shown in the following example commands:Copied to your clipboardbin/magento events:subscribe observer.catalog_product_save_after --fields=sku --fields=stock_data.qtyCopied to your clipboardbin/magento events:subscribe observer.customer_login --fields=firstname --fields=lastname --fields=entity_idWarning: When you use the
events:subscribe
command to subscribe to events on a Cloud environment, configuration information is stored in theapp/etc/config.php
file. You must keep in mind that this file can be replaced with theapp/etc/config.php
file from Git during deployment. As a result, the event subscription will be replaced as well. To make these changes permanent, manually add the appropriate configuration to theapp/etc/config.php
file under Git.If you have a module ready or have specific events in mind, see Register events for more information.
Return to your workspace. Click the Add service pop-up menu and select Event.
On the Add events page, select Commerce events. Then click Next.
Note: If the Commerce events category is not shown, check that you have created an event provider, and that it has at least one subscribed event. You may need to run the
bin/magento events:metadata:populate
command to synchronize event registrations in Adobe Commerce with the created event provider.On the Configure event registration page, select your event provider. Then click Next.
Select the events to subscribe to. Then click Next.
Optionally create a new OAuth or JWT credential. Then click Next.
Update the Event registration name and Event registration description fields. In the How to receive events section, under Option 2, select the runtime action you created in Set up App Builder and define a runtime action.
Select Save configured events.
You are now set up to develop your App Builder extension.
Check cron and message queue configuration
Cron and message queues must be enabled. Commerce uses the event_data_batch_send
cron job to transmit batches of event messages and the clean_event_data
cron job to remove these messages from the database. These cron jobs are part of the default
group.
The commerce.eventing.event.publish
message queue consumer helps expedite registered events that have been designated as priority. The consumer processes priority events within a second of their receipt. By default, it can take up to 59 seconds for cron to process standard-priority events.
In Adobe Commerce on cloud infrastructure, update your .magento.env.yaml
file with the following changes to the global
and deploy
stages:
Copied to your clipboardstage:global:ENABLE_EVENTING: truedeploy:CRON_CONSUMERS_RUNNER:cron_run: truemax_messages: 0consumers: []
The deployment process might become stuck if the consumer runs in the background. The Troubleshooting topic describes how to resolve this condition.
See Global variables for more information about the ENABLE_EVENTING
variable.
Cloud infrastructure and on-premises instances require different cron management procedures as described here: