Event Handling in AEM 6.4 | Community
Skip to main content
Level 3
July 19, 2018

Event Handling in AEM 6.4

  • July 19, 2018
  • 3 replies
  • 9445 views

Hi,

We have various event handlers which are not working in 6.4 since various attributes(resourceChangedAttributes etc.) are removed from Sling Events.  I was wondering if Adobe I/O Event handling can be a potential solution??  Has anyone tried this ?

Thanks,

Rachna

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

3 replies

arunpatidar
Community Advisor
Community Advisor
July 19, 2018

Hi,

you can use JCR events.

AEM 6.3 Event problem

Arun Patidar
smacdonald2008
Level 10
July 19, 2018

Agree with Arun - JCR Events are lower level API then Sling Events.

Level 3
July 19, 2018

Thanks both!

JCR Events has an issue when it comes to getting admin session, it's not allowing to get session using standard sys users way, and it requires to use deprecated method repository.loginAdministrative(null) & whitelisting the bundle to get the session;

I was thinking to go for higher level Page topics or Adobe I/O events for aem, any idea which is better compare to JCR events as deprecation is strongly discouraged as far as I know!  I wanted to try Adobe I/O and it supports custom osgi events too.

Thanks,

Rachna

arunpatidar
Community Advisor
Community Advisor
July 19, 2018

Hi,

You can try below to get Session using below to observe JCR events.

session = repository.loginService("subservice-name", null);

you need to create subservice to use system user and create mapping through web console

e.g.

session = repository.loginService("readService", null);

this will create session with training-user

aem63app-repo/SampleJCRUGD.java at master · arunpatidar02/aem63app-repo · GitHub

Thanks

Arun

Arun Patidar
Level 2
February 6, 2019

Hi Arun,

Many thanks for the help, I replaced maven scr plugin with OSGI annotations plugin and looks like I am able to get the repository now but I am getting exception when I try to register event handler using observationManager object.

It throws exception on following line.

observationManager.addEventListener(this, Event.PROPERTY_ADDED | Event.PROPERTY_CHANGED | Event.PROPERTY_REMOVED, "/content/SITEROOT/**/jcr:content/**", true, null,

   new String[] {"cq:PageContent"} , true);

Any idea?

Once again thank you for sending the link to upgrade deprecated scr plugin to osgi annotations libraries.

Thanks & Regards,

Rachna


rachanam15474013​ Hi Rachana, I am facing exact same issue. Could you please update the fix here .

Level 3
March 29, 2019

anjalishyamsundar​  Hi yeah you can try JCR Events but I didn't use it because it's not cluster safe and very low level, requires lot of filtering in the code before we reach to interested event.  I am also not using osgi annotations so that's another blocker for me to go for JCR Events.