Hi Justin

EventAdmin will getService and ungetService the matching EventHandler services 
for each event to be dispatched. If the component is a delayed service, which 
as you state is the default, this means the instance is created and dropped for 
every single event. If there are a lot of them, this will place some load on 
the system.

If there are not many events, it might indeed be better to make it a delayed 
service component.

I think there once has been a discussion on some list (I cannot remember where 
or when, sorry) coming to the conclusion, that EventHandler services better be 
immediate.

Regards
Felix

> Am 10.11.2016 um 15:17 schrieb Justin Edelson <jus...@justinedelson.com>:
> 
> Hi,
> It has been pointed out to me that on
> https://sling.apache.org/documentation/tutorials-how-tos/how-to-manage-events-in-sling.html#starting-a-job,
> the sample code shows an EventHandler which has @Component(immediate=true).
> 
> As far as I know, this is an anti-pattern. The use of immediate=true is
> unnecessary for EventHandlers (in general) since DS will automatically
> activate them when/if an event matches the filter.
> 
> Is this understanding correct? Is there a reason our documentation has
> immediate=true here?
> 
> Regards,
> Justin

Reply via email to