JCR Listener: receiving events in "bundle" | Community
Skip to main content
JS_Bournival
Level 3
October 16, 2015
Solved

JCR Listener: receiving events in "bundle"

  • October 16, 2015
  • 2 replies
  • 849 views

Ok JCR experts, there's something I need to know:

I registered a JCR listener to catch NODE_MOVED and NODE_REMOVED events.  This is working well.  The method we need to override when implementing the EventListener interface, onEvent, receives an EventIterator.  So sometimes, events are bundled together.  What's the rule here? Is there even one? The spec doesn't tell.

For instance, when moving a tag in CQ5 tagging UI, my listener receives 1 bundle of 2 events (sometimes 3):

a NODE_REMOVED event:  source node is deleted
a NODE_MOVED event: to reflect the move operation with the source/dest path
sometimes, there's a 3rd event in there, another NODE_REMOVED event, but with another node ID and I have no idea what it represents
​So here I can see why they are bundled together: there's a relationship between them, they're kind of part of the same "atomic" operation.  But can I rely on this?

Thank you so much.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by joerghoh

Hi,

It isn't specified, which and how much events you will get in a single call of your event handler. In Jackrabbit 2.x (and therefor CRX 2.x) ever call of session.save() is dispatched to a single transaction, and you will receive all events caused by this transaction if it is succesfully dispatched. I don't know how this will behave in upcoming releases.

Jörg

2 replies

smacdonald2008
Level 10
October 16, 2015

Here are some good topics / specifications to reference - (you have referenced some already):

http://www.day.com/specs/jcr/1.0/8.3.1_Event_Listeners.html

http://www.day.com/specs/jcr/2.0/12_Observation.html

http://www.day.com/maven/jsr170/javadocs/jcr-2.0/javax/jcr/observation/EventListener.html

Here is another good piece of content about this subject that may be helpful:

http://experiencedelivers.adobe.com/cemblog/en/experiencedelivers/2012/04/event_handling_incq.html -- this content discusses different ways of JCR Event handling within CQ and talks about pros and cons of each way. 

Hope this helps.

joerghoh
Adobe Employee
joerghohAdobe EmployeeAccepted solution
Adobe Employee
October 16, 2015

Hi,

It isn't specified, which and how much events you will get in a single call of your event handler. In Jackrabbit 2.x (and therefor CRX 2.x) ever call of session.save() is dispatched to a single transaction, and you will receive all events caused by this transaction if it is succesfully dispatched. I don't know how this will behave in upcoming releases.

Jörg