org.apache.sling.event.EventUtil api is depricated in AEM 6.2 | Community
Skip to main content
Level 2
Mar 23, 2017 12:33 PM UTC
Solved

org.apache.sling.event.EventUtil api is depricated in AEM 6.2

Hi Team,

    In one of our application, the code contains org.apache.sling.event.EventUtil and in order to find a local event in a clustered environment it uses EventUtil.isLocal(event) method. Until version AEM 6.0 it was working fine as expected. But in AEM 6.2, the above has been deprecated.

Could you please suggest any alternatives for the same?, Thanks.

Regards,

Saran 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
MeTooTwoAccepted solution
Employee
Mar 23, 2017 5:38 PM UTC

You could filter at the event handler level. If you're using annotations, add the filter line.

@Properties({ @Property(name = "event.topics", value = "com/mycompany/app/eventname", propertyPrivate = true),
@Property(name = EventConstants.EVENT_FILTER, value="(!(" + DEAConstants.PROPERTY_APPLICATION + "=*))")})

If the event is a local event, the PROPERTY_APPLICATION is not available. If it is available, it contains the application (Sling ID) of the instance where the event originated.

3 replies

Level 2
Mar 13, 2019 10:06 AM UTC

Hi Team,

6.1 to 6.4 migration:

Could you please let me know how to get the EVENT_FILTER value or PROPERTY_APPLICATION value?

Here is my code correct me if I am wrong

@Properties({ @Property(name = EventConstants.EVENT_TOPIC, value = {ReplicationAction.EVENT_TOPIC,AlertSender.JOB_TOPIC}, propertyPrivate = true),

@Property(name = EventConstants.EVENT_FILTER, value="(!(" + DEAConstants.PROPERTY_APPLICATION + "=*))")})

@Override

    public void handleEvent(Event event) {

//String localevent = (String)event.getProperty("event.filter");-- commented

String localEvent=(String)event.getProperty(DEAConstants.PROPERTY_APPLICATION);

if(StringUtil.isBlank(localEvent)){

        //JobUtil.processJob(event, this); -- Need to replace this method also please let me know how to use jobConsumer interface here

      

        }

}

Translate
Saran_KAuthor
Level 2
Mar 24, 2017 1:48 PM UTC

Hi Tony,

    Thanks a lot for this solution. It will satisfy our needs. Many Thanks again. smiley

Translate
MeTooTwoAccepted solution
Employee
Mar 23, 2017 5:38 PM UTC

You could filter at the event handler level. If you're using annotations, add the filter line.

@Properties({ @Property(name = "event.topics", value = "com/mycompany/app/eventname", propertyPrivate = true),
@Property(name = EventConstants.EVENT_FILTER, value="(!(" + DEAConstants.PROPERTY_APPLICATION + "=*))")})

If the event is a local event, the PROPERTY_APPLICATION is not available. If it is available, it contains the application (Sling ID) of the instance where the event originated.

Translate