Register/Map Custom AEM I/O Events
After setting up AEM I/O events following this, you will get the following AEM events mapped to I/O events OOTB and you can immediately hook them up with your I/O actions or webhooks.
What if you want to map more AEM event types into I/O events such as asset_published
or asset_metadata_updated
? Here are the high-level steps. In general, what it takes is just to find the underlying OSGi event and map to a new I/O event code through a custom com.adobe.aio.aem.event.osgimapping.internal.OsgiEventMappingSupplierImpl
factory config. Let's take asset_published
and asset_metadata_updated
events as examples.
asset_published
- Publish an asset and go to /system/console/events to find the event that can be uniquely identified by the event topic, path, and type. something like below,
- Use event topic, path, and type to define a custom OSGi config
com.adobe.aio.aem.event.osgimapping.internal.OsgiEventMappingSupplierImpl-asset_published.cfg.json
with below properties,
A few things to note,
- This event only indicates asset is published from author, not necessarily meaning the asset has successfully reached to each publisher. For the latter, you can use osgi event topic
org/apache/sling/distribution/agent/package/distributed
. com.adobe.xdm.event.AemPagePublishedEvent
is reused asadobeIoXdmEventClassName
(same aspage_published
event) for constructing the I/O XDM event payload.AemPagePublishedEvent
providesxdmPublished
as the event type.!(event.application=*)
is added to theosgiFilter
to avoid the same event being emitted multiple times especially for clustered authors in AEMaaCS.- Once this config is deployed, an event payload would look like this in I/O console’s Debug Trace after you publish an asset.
asset_metadata_updated
- Update an asset’s metadata and go to /system/console/events to find the event that can be uniquely identified by the event topic, path, and type. something like below,
- Use event topic, path, and type to define a custom OSGi config
com.adobe.aio.aem.event.osgimapping.internal.OsgiEventMappingSupplierImpl-asset_metadata_updated.cfg.json
with below properties,
- Once this config is deployed, an event payload would look like this in I/O console’s Debug Trace after you update an asset’s metadata.
You may notice asset_metadata_updated
event is always followed whenever an asset_published
event is fired. This is because certain metadata like cq:lastReplicated
, etc. is updated after an asset is published.
The above mechanism can be extended to map custom OSGi/Sling events as long as your custom event can be uniquely identified by topic, path, and type.
The new AEM event types should be available in your I/O project for registration like this,
More references can be found at https://www.adobe.io/apis/experienceplatform/events/docs.html#!adobedocs/adobeio-events/master/aem/aem_advanced_configurations.md.