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 3, 2017

Does the Event handler fire when you create a 2nd page?


Also - what AEM version are you using and how are you getting the Session?