Skip to main content
Level 1
Nov 20, 2026 5:57 PM UTC
Question

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

1 reply

Mani_kumar_
Community Advisor
Community Advisor
Nov 21, 2026 2:53 PM UTC

Short answer: yes, and your own test already proves it. The denial is the Felix EventAdmin doing exactly what it is designed to do, and the fix you made (filter in handleEvent, hand the addJob call to another thread) is the pattern Adobe's own answers recommend. One refinement: don't hand-roll the thread, use the Sling ThreadPoolManager.

 

Why the handler was denied

 

Apache Felix EventAdmin, which AEM uses, gives every synchronous event handler a timeout. The default is 5,000 ms (property org.apache.felix.eventadmin.Timeout). If a handler takes longer than that to process one event, it is deny-listed, and once deny-listed it is sent no further events. That matches your symptom exactly: one slow addJob call under repository load, then silence until the pods were replaced.

 

1) Is handing job creation to your own thread supported on AEM as a Cloud Service?

 

Yes. This is the endorsed pattern, not a workaround. Adobe's own community answers say the same thing: an event handler should return as fast as possible, and if the work takes longer, offload it, "feeding a queue where a dedicated threadpool is picking the work from, or creating Sling Jobs". Your change does exactly that, and 850 test assets in three bursts with no denial and no queue error is the validation.

 

2) Should you use the Sling ThreadPoolManager instead of your own executor?

 

Yes, use the ThreadPoolManager. Adobe KB KA-28172 (August 18, 2026) says to "Replace Java native ThreadPool with Sling-provided ThreadPoolManager for all background processes in AEM services." The Sling documentation shows the shape:

 

@Reference

private ThreadPoolManager threadPoolManager;

 

@Reference

private JobManager jobManager;

 

private ThreadPool pool;

 

@Activate

protected void activate() {

    pool = threadPoolManager.get("dam-post-processing");

}

 

@Deactivate

protected void deactivate() {

    threadPoolManager.release(pool);

}

 

@Override

public void handleEvent(Event event) {

    // filter on event type and path, then copy out what the job needs

    Map<String, Object> props = new HashMap<>();

    pool.execute(() -> jobManager.addJob("com/example/dam/postprocess", props));

}

 

The pool is configurable through OSGi with the "Apache Sling Thread Pool Configuration" factory (name, min/max pool size, queue size, graceful shutdown). Two settings matter for your case: set a bounded queueSize (the default is -1, unlimited, so a burst can grow memory without bound) and set shutdownGraceful to true (without it, tasks still queued when the pool shuts down are dropped, not run). One or two threads are enough for the hand-over itself; addJob is fast when the repository is not contended, and the bottleneck you hit was repository load, not CPU. If you call threadPoolManager.get() with a name that has no factory configuration, you get a pool with the default settings, so the code works first and the configuration is the tuning step.

 

3) The in-memory queue is lost if a pod stops. Is a periodic sweep the recommended safety net?

 

Yes, a sweep is the right safety net, with one important detail: once addJob returns, the job itself is persistent (Sling Jobs are stored in the repository), so the only hand-overs at risk are the ones still sitting in the in-memory queue when the pod stops. That is a small, bounded window, and the sweep covers it.

 

Build the sweep as a Sling Scheduled Job, not a plain Sling Scheduler task. Adobe's AEM as a Cloud Service code quality rules say not to use the Sling Scheduler for tasks that require guaranteed execution, because Sling Scheduled Jobs guarantee execution and are better suited to clustered environments. The sweep needs one durable thing to query: have the JobConsumer write a marker (a property or a node) when it finishes an asset, and the sweep looks for assets in the processing-completed state without that marker, then re-enqueues them. Make the JobConsumer idempotent (check for the marker before doing the work), so re-enqueueing an asset that was already processed is a harmless no-op.

 

The alternatives you asked about: AEM Events (Adobe I/O Events) can push asset events to an external webhook, but that is an external integration and heavier than an in-AEM sweep for this. A post-processing workflow step is not the right place: it runs inside the DAM Update Asset workflow, and putting the hand-over there puts blocking work back into a thread you do not control.

 

4) Is org.apache.felix.eventadmin.IgnoreTimeout accepted as an OSGi configuration on AEM as a Cloud Service?

 

No, and it is the wrong lever. IgnoreTimeout is not a property you set on your handler. It is a property of the EventAdmin service itself (configuration PID org.apache.felix.eventadmin.impl.EventAdmin): a list of handler class names or package patterns that are exempt from the timeout. On AEM as a Cloud Service that service is Adobe-managed, and there is no documented customer path to configure that PID. The on-premise thread you linked set it through a repository configuration, which does not exist on Cloud Service.

 

Even where it can be set, do not use it for this. The Felix documentation calls it "a pure optimization" and says "the application should work without this configuration property". It only removes the safety net: a slow handler then blocks the EventAdmin delivery thread, which delays every other synchronous handler. Your offload is the fix; IgnoreTimeout would just hide the next slow call. If you believe you need it, the route is Adobe Support, not a configuration you deploy.

 

5) Is there Adobe documentation on event handler timeouts to cite?

 

Honestly, no: Adobe does not publish AEM as a Cloud Service documentation on the EventAdmin timeout. What you can cite:

 

- Apache Felix EventAdmin documentation: the timeout (default 5,000 ms) and deny-listing behaviour, and the IgnoreTimeout property.

- Apache Sling Commons Thread Pool documentation: ThreadPoolManager, named pools, and the factory configuration.

- Adobe KB KA-28172: replace Java native thread pools with the Sling ThreadPoolManager for background processes.

- Adobe AEM as a Cloud Service Custom Code Quality Rules: do not use the Sling Scheduler for work that needs guaranteed execution.

- The two community answers you found: the rule of thumb that a handler should return as fast as possible and offload longer work to a dedicated threadpool or Sling Jobs, and the earlier thread confirming that a slow handler is blacklisted (deny-listed).

 

Verify it: re-run your burst test with the ThreadPoolManager version and confirm no denial; then stop a pod (or deactivate the component) with hand-overs queued and confirm the sweep picks them up on its next run.

Translate