Event Handler not working on second time | Community
Skip to main content
AEMLearner-1989
Level 4
August 3, 2017

Event Handler not working on second time

  • August 3, 2017
  • 1 reply
  • 6736 views

Hi Team,

I am trying to create a event handler for deleting a page.First time ,  its calling up... but second time its not calling handleEvent() method..any clue??

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

1 reply

smacdonald2008
Level 10
August 3, 2017

What API are you using?

AEMLearner-1989
Level 4
August 3, 2017

Simple code snippet:

@Component(immediate = true)

@Service

@Property(name = EventConstants.EVENT_TOPIC, value = "com/day/cq/wcm/core/page")

public class SimpleResourceListener implements EventHandler{

  public SimpleResourceListener(){

  System.out.println("inside construc");

  }

  private Logger log =LoggerFactory.getLogger(this.getClass());

  public void handleEvent(Event event) {

  // TODO Auto-generated method stub

  System.out.println("inside hanlder");

  }

Now when I create a page, this handler reacts and logs the string "inside handler". Now when I activate the page second or third time, the Event handler does not react

smacdonald2008
Level 10
August 4, 2017

viveksachdeva

Hi , Sorry .. I am not trying to replicate the page  ...

I wanna trigger a event when i try to create a page or delete a page ...

So first time event is calling properly but not second time...

Example :

test - cq:page - working

test1-cq:page - not working


In the HELPX article - it states. Have you configured your event handler to not timeout?

Blacklist

Event handling in Sling by default may timeout your event handler. To configure your event handler to ignore a timeout, perform these tasks:

  1. Go to http://:/system/console/configMgr.
  2. Select Configuration.
  3. Select "Apache Felix Event Admin Implementation".
  4. You should see a list for ignore timeout, specify your package in that list.