Tag: Liferay scheduler

Liferay 7 Scheduler

According to software environment Scheduler is mainly used to run program automatic offline. Scheduler calls the service, performs the appropriately assigned task and does its job.

Schedulers are the java processes which trigger certain logic after every specified interval. Schedulers are very important aspect of software development these days. Liferay provides a flexible way for scheduler implementation. Today we will discuss on scheduler implementation on Liferay 7.
Pre-requisites:– Java 1.8 – Liferay 7 must be installed. – Liferay Developer studio And if you haven’t configured your Liferay Server with Developer studio, here are the steps.. Go to window → Preferences → Server → Runtime Environment and then add the server.

Create module in Liferay workspace: To create Liferay modules, Select Modules → Right Click → New → Liferay Module Project. Give appropriate name and click finish.

Project structure will be created in workSpace.

Now create one class named as LiferayScheduler with package name as com.enprowess.schedulerclass.

Liferay7 provides one class that named as BaseSchedulerEntryMessageListener which contains methods related to Scheduler.


Our class LiferayScheduler will extend this BaseSchedulerEntryMessageListener class, that will provide all methods where we have to code in an appropriate method as doReceive(), activate().


For calling scheduler, we use a doReceive method, where we write our logic that will be executed based on defined time interval.


protected void doReceive(Message message) throws Exception {
log.info(“I will be called at every twenty-four hours”);




As Liferay7 doesn’t contain any xml file to define time interval for scheduler , so we need to configure everything in class itself only. To define time interval there is one method called as activate () where we define the interval.



protected void activate() {

schedulerEntryImpl.setTrigger (
TriggerFactoryUtil.createTrigger(getEventListenerClass(), getEventListenerClass(), 24, TimeUnit.HOUR));

_schedulerEngineHelper.register(this, schedulerEntryImpl, DestinationNames.SCHEDULER_DISPATCH);

Here we can change the value of 24 based on our requirements with relevant time unit as hour, minute, seconds.

Now Once we deploy this portlet to server, our service will be called at every twenty-four hours.