Tuesday, September 28, 2010

Liferay 6- Scheduler Engine design change

In Liferay 5.2.x, we had com.liferay.portal.kernel.job.IntervalJob as a Quartz scheduler job, which needs to be implemented for different jobs we need for Quartz trigger execution.

In Liferay 6, the design pf scheduler engine has been changed and introduced combination with JMS. I have prepared the small class cum collaboration diagram, which can help understanding how we need to make triggers now onwards.

Basically, they made use of messaging with Quartz. The Job class for liferay is now fixed which is com.liferay.portal.scheduler.job.MessageSenderJob .

Now we have a com.liferay.portal.kernel.messaging.MessageListener which is to be implemented for different job handling.

The schedulerEnginUtil class will register the listener with perticular queue destination and schedules new trigger as per the SchedulerEntry details with MessageSenderJob. When trigger fired, this Job class will eventually sends message to queue, which will eventually go to the listener.

This time, not as like previous scheduler, they have given exposure to Message which can contain some payload data if needed for job execution. This is very helpful sometimes.

By default the method schedule(SchedulerEntry schedulerEntry, ClassLoader classLoader)from SchedulerEngineUtil sends null Message. So, we might need to copy and pass some payload object if needed.


Anonymous said...

Hello Parth,

First of all thanks for the nice article.
I am using Liferay6EE and created a job by implementing MessageListener Interface and its working fine.

Now I want to develop a job scheduler admin panel from where I can manage this job like schedule, start, stop..

Please provide some idea how can I start with the implementation.

Thanks in advance

Parth Barot said...

Actually liferay uses Quartz for scheduling purpose. Quartz stores all the data related to scheduled triggers in DB.

As i have explained, we need to implement the job class and MessageListener. But, if we want to start, pause/start, stop it then you must keep track of triggers. All triggers you will find in quartz tables & also the job data.

[There should be 12 tables in your Liferay DB. Please check that].

Anonymous said...

hello prth,

thank u from me to but i have the same problem.

i need to configure the jobs at server runtime without restart!? is it possible?

as i see from your comment from 3.nov i have to manipulate the db directly?

i think there is no com.liferay.portal.scheduler.job.MessageSenderJob anymore or am i wrong?

i'm new to liferay (using lr6.0eeSp2) and can't find any usefull documents:(

Thank you for help..