Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

AEM6.4 - Execute Event Handler on Activation workflow

Avatar

Level 3

Hi,

I am facing the problem below.

I have a workflow to publish a content on a specific node when it is updated.

On the other hand, I have an action on my bundle that has to be executed when this content is activated.

I am following this tutorial below. but my class is not been called when workflow is completed. I realized that this class is using some deprecated method.

Adobe CQ Help | Creating Replication Event Handlers for Adobe Experience Manager

Has someone implemented this on AEM6.4? If so, is there a most current tutorial?

My class does not have errors, but does is not working as well.

I appreciate any help.

Thanks in advance.

5 Replies

Avatar

Community Advisor

Do not use the EventHandler anymore. You can use the Resource Change Listener to listen to node event and implement any custom operations.

acs-aem-samples/SampleResourceChangeListener.java at master · Adobe-Consulting-Services/acs-aem-samp...

You can follow this example however it contains Felix annotations. Attaching sample code with OSGI annotations:

@Component(

        service = ResourceChangeListener.class,

        property = {

                ResourceChangeListener.PATHS + "=" + "/<add path here>",

                ResourceChangeListener.CHANGES + "=" + "ADDED"

        }

)

public class Sample implements ResourceChangeListener {

    @Override

    public void onChange(@Nonnull List<ResourceChange> list) {

        try {

            for (final ResourceChange change : list) {

               

            }

        } catch (Exception e) {

            LOGGER.error("Exception {}", e);

        }

    }

}

Hope, it helps.

Hi,

thank you very much for your answer!

So, I noticed that the events that I am able to use are "ADDED", "CHANGED", "REMOVED", but there is not replication events.

If I use changed event for example, the class will be called when the change is on author mode and when the change is on publish mode as well?

Thank you once more!

Avatar

Level 3

Thank you, but it was told to me to not use Event Handler anymore.

I am already using OSGI annotations but ResourceChangeListener does not have an event type to identify the replication of a node,

how can I identify a replication of a node and then call some method???

Avatar

Level 1

@elizabethp60981 , Did you get the replication event listener? If Yes, please share how you implemented the replication or activation event handler.

Thanks in advance.