ResourceChangeListener v/s Sling Event


With introduction of ResourceChangeListener, this blog is an effort to help developers choose between ResourceChangeListener and Sling Event for an implementation.

ResourceChangeListener:

pros:

  • Can be configured to listen to only specific paths. Multiple watch paths can also be configured to provide it a more granular approach.
  • For a bulk operation concerning N resources, listener will be executed ONLY once. Thus, total number of persistence operations = 1 (via handler) + 1 (Bulk operation) = 2

cons:

Sling Event:

pros:

cons:

  • Cannot restrict events to a certain path. Sling Event listens to all nodes starting from the root node of a repository (/)
  • For a bulk operation concerning N resources, handler will be called N times. Thus, total number of persistence operations = N (via handler) + 1 (Bulk operation) = N + 1

2 thoughts on “ResourceChangeListener v/s Sling Event

  1. The new observation listener has one really big disadvantage. It cannot isten on concrete resource type, which is ridicolous. There is only information about path which is useless in real world

    Like

Leave a comment