Push Publish Listeners Configuration - Documentation topics on: dotcms configuration,push publishing,.

Push Publish Listeners Configuration

dotCMS allows the tracking, logging, and customized actions, based on push publish events as they occur. Customizations to these event listeners can be activated and managed via the OSGI plugins manager under “Dev Tools” on the dotCMS backend UI.The following event listeners can be configured:

  • AddedToQueueEvent.java: Listener for push publishing events added to the push publishing queue
  • AllEndpointsFailureEvent.java: Push publishing has failed
  • AllEndpointsSuccessEvent.java: Push publishing has succeeded
  • PushPublishEndEvent.java: Push publishing event has ended
  • PushPublishStartEvent.java: A push publishing event has started
  • SingleEndpointFailureEvent.java: Push publishing has failed on a specific endpoint

Plugin Github Repository

The github plugin directory where you can download the com.dotcms.pushpublish.listener plugin is: https://github.com/dotCMS/plugin-seeds.git

Inside the com.dotcms.pushpublish.listener, in the following path: com.dotcms.pushpublish.listener/src/main/java/com/dotcms/pushpublish you will find Activator.java and a listener folder with some example java classes that activate the listeners. Modify the Activator.java file and add the java files for the listeners that you wish to activate and customize behavior for inside the /listener directory.

Subscribing to Push Publishing Events

There are two ways to subscribe to Push Publishing events:

1) Implementing EventSubscriber.java as in this example

Ex: https://github.com/dotCMS/plugin-seeds/blob/master/OSGi/com.dotcms.pushpublish.listener/src/main/java/com/dotcms/pushpublish/listener/SuccessEndpointsSubscriber.java

package com.dotcms.pushpublish.listener;


    import com.dotcms.system.event.local.model.EventSubscriber;
    import com.dotcms.system.event.local.type.pushpublish.AllEndpointsSuccessEvent;

    /**
     * Sample class
     */
    public class SuccessEndpointsSubscriber implements EventSubscriber<AllEndpointsSuccessEvent> {


        public void notify(AllEndpointsSuccessEvent event) {
            System.out.println("Successfully pushed to all endpoints");
        }

    } // EOC MySample

- OR -

2) Using @Subscriber annotation in the method that configures the action to be executed

Ex: https://github.com/dotCMS/plugin-seeds/blob/master/OSGi/com.dotcms.pushpublish.listener/src/main/java/com/dotcms/pushpublish/listener/PushPublishStartSubscriber.java

package com.dotcms.pushpublish.listener;


    import com.dotcms.system.event.local.model.Subscriber;
    import com.dotcms.system.event.local.type.pushpublish.PushPublishStartEvent;

    public class PushPublishStartSubscriber {
        @Subscriber
        public void notify(PushPublishStartEvent event) {
            System.out.println("Executing subscriber for " + event.getName());
        }
    }

It is EXTREMELY IMPORTANT to remember to include the unsubscriber method for every listener in the Activate.java file so that if the plugin is shut down thru the UI, that the listener will also be shut down. Otherwise, the listeners will keep running, even after the plugin is undeployed. Both of these subscription implementation methodologies have the same behavior.

How to Deploy the Push Publishing Listeners Plugin

Once you have modified the Activator.java and added the java files to the listener directory, then run ./gradlew jar which will create the com.dotcms.pushpublish.listener-0.1.jar file that you can upload and deploy from the dotCMS backend UI under Dev Tools -> Plugins.





After activating the plugin, the plugin can also be either stopped or undeployed completely.