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
  • 9449 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
arunpatidar
Community Advisor
Community Advisor
July 20, 2018

Hi Arun,

thanks for the message.

Please find imports which I am using.

import org.apache.felix.scr.annotations.Reference;

import org.apache.sling.jcr.api.SlingRepository;

import org.osgi.service.component.ComponentContext;

import org.osgi.service.component.annotations.Component;

import org.slf4j.Logger;

import org.slf4j.LoggerFactory;

import javax.jcr.Session;

import javax.jcr.observation.Event;

import javax.jcr.observation.EventIterator;

import javax.jcr.observation.EventListener;

import javax.jcr.observation.ObservationManager;

Yes you are right, it doesn't work for JCR events.

Thanks,

Rachna


Hi Rachna,

If you are  able to get session using resourceResolver that means your service is good.

Now I am wondering why it is not working for when you are getting session using repository.

Could you please try with my code, It works fine. I've just checked in AEM6.4

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

Thanks

Arun

Arun Patidar
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.