Event handler denied after 5 s on AEMaaCS: is handing Sling job creation to a dedicated thread a supported pattern?
We have an OSGi EventHandler on the DAM "asset processing completed" event (AEM as a Cloud Service, author). It only checks the event type and a path, then calls JobManager.addJob(...). The real work runs in a Sling JobConsumer.
On a pre-production environment whose repository was under heavy load, one addJob call took longer than 5 seconds. Felix Event Admin then logged "EventAdmin: Denying event handler ... due to timeout!" and the handler received no further events until the pods were replaced. There was no error in our own code.
Fix we made: handleEvent now only filters and returns. The addJob call runs on a single daemon thread that the component creates in @Activate and stops in @Deactivate. After the change, 850 test assets in three bursts produced no denial and no queue error.
This matches advice we found in older answers by Adobe employees on this forum ("offload the actual handling of the listener into a dedicated threadpool" and "feeding a queue where a dedicated threadpool is picking the work from, or creating Sling Jobs"), but we could not find it in the Cloud Service documentation. Questions:
1) Is handing the job creation to an own thread a supported pattern on AEM as a Cloud Service?
2) Should we use the Sling ThreadPoolManager instead of our own executor?
3) The hand-over queue is in memory, so queued hand-overs are lost if a pod stops. Is a periodic sweep for unprocessed assets the recommended safety net, or is there a better trigger (for example a post-processing workflow step or AEM Events)?
4) Is org.apache.felix.eventadmin.IgnoreTimeout accepted as an OSGi configuration on AEM as a Cloud Service?
5) Is there Adobe documentation on event handler timeouts that we should cite?
The older answers I mean: https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/custom-replication-event-handler-not-triggering-intermittently/m-p/279325 and https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/aem-6-5-how-to-make-event-listener-not-wait-for-an-event-to/m-p/390480