Question

Standard timeout of Apache Felix Event Admin Implementation in felix->configuration is 5000ms. Now how to allow one or more event handler to take longer time (with pleasure programmatically)?

Was it helpful?

Solution 2

You can change any OSGi configuration programatically via the ConfigurationAdmin service described at http://www.osgi.org/javadoc/r4v42/org/osgi/service/cm/ConfigurationAdmin.html

You'll need the PID of the configuration that you want to change (the OSGi admin console or shell will provide that). Use ConfigurationAdmin.getConfiguration(..) to retrieve the corresponding Configuration object, and call Configuration.update(...) with the changed properties.

That being said, raising the events blacklisting timeout is usually a bad idea - event handlers that take a long time to run will block things. Use separate threads or jobs (as suggested by Chris Leggett) to do the slow work.

OTHER TIPS

If you don't want your event handler to be subject to blacklisting, you can execute the event as a job. Jobs are not subject to blacklisting and are guaranteed to run. See http://experiencedelivers.adobe.com/cemblog/en/experiencedelivers/2012/04/event_handling_incq.html for more info on processing a job from an event handler and http://sling.apache.org/apidocs/sling6/org/apache/sling/event/jobs/JobUtil.html#processJob(org.osgi.service.event.Event,%20org.apache.sling.event.jobs.JobProcessor) for executing your JobProcessor.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top