Foren

Home » Liferay Portal » English » 3. Development

Kombinierte Ansicht Flache Ansicht Baumansicht
Threads [ Zurück | Nächste ]
toggle
parth barot
Liferay 6-Scheduler Engine design change...
28. September 2010 22:38
Antwort

parth barot

Rang: Junior Member

Nachrichten: 42

Eintrittsdatum: 30. April 2010

Neue Beiträge

Hi all,

This is regarding how Liferay 6 has changed the design of scheduler engine and handling of jobs. This might helpful because its totally different then previous, and i gone through it for my work. I thought of sharing so many of you can check and easily migrate...

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 .

I have made entry in my blog, please check the link below for full.


http://javalibs.blogspot.com/2010/09/liferay-6-scheduler-engine-design.html

thanks,
Parth.
Sandeep Nair
RE: Liferay 6-Scheduler Engine design change...
29. September 2010 05:40
Antwort

Sandeep Nair

Rang: Liferay Legend

Nachrichten: 1692

Eintrittsdatum: 5. November 2008

Neue Beiträge

Awesome. thanks for sharing
gianluca maranzana
RE: Liferay 6-Scheduler Engine design change...
19. November 2010 08:07
Antwort

gianluca maranzana

Rang: Junior Member

Nachrichten: 26

Eintrittsdatum: 30. Juli 2008

Neue Beiträge

Good and useful, thanks to you.

So I've prepared this "dummy" step-by-step job's migration from 5.x to 6.0:

1) implement your com.liferay.portal.scheduler.job.MessageSenderJob (was com.liferay.portal.kernel.job.IntervalJob)
2) implement your com.liferay.portal.kernel.scheduler.SchedulerEngine (was com.liferay.portal.kernel.job.Scheduler,
that was contain an org.quartz.Scheduler)
3) previously, you put your custom Schedulerxxx.java in liferay-portlet(-ext).xml under <scheduler-class> tag,
now to go live your job class, put a bean in scheduler-spring(-ext).xml (not recommended, see 3-a) )

ALSO take a look to theese points:

2-a) implement a class that uses IntervalTrigger or use the trigger that you prefer, and
instantiate for use in your SchedulerEnginexxx.schedule() call (the one used for IntervalJob was IntervalTrigger...
but CronTrigger it's a good thing too)

3-a) as you can see, in public class QuartzSchedulerEngineImpl implements SchedulerEngine:
1....
2schedulerFactory.initialize(PropsUtil.getProperties("org.quartz.", false));
3...


It Get out jobs from somewhere properties, so you can put simply in portal-ext.properties
your custom scheduler (NOT recommended, for me):
1....
2org.quartz.scheduler.instanceName=QuartzSchedulerEngineInstance
3....


(RECOMMENDED, 'cause this way adds your schedulers to default one..)
Add your custom Job(s) under (don't worry about wrong class path in comment,
the right one is like above: com.liferay.portal.kernel.scheduler.SchedulerEngine):
1
2... #
3    # Input a list of comma delimited class names that implement
4    # com.liferay.portal.kernel.job.Scheduler. These classes allow jobs to be
5    # scheduled on startup. These classes are not associated to any one portlet.
6    #
7    scheduler.classes= com.ext.liferay.portal.kernel.scheduler.SchedulerEnginexxx, ....
Miguel Coxo
RE: Liferay 6-Scheduler Engine design change...
29. Dezember 2010 11:11
Antwort

Miguel Coxo

Rang: New Member

Nachrichten: 16

Eintrittsdatum: 1. März 2010

Neue Beiträge

Hello there,

So i was trying to use the scheduler in liferay and i couldn't understand the steps described here. I went to the IRC channel and jhf helped me figure out how to schedule a job in liferay 6.

So here is what you need to do to make a job and schedule it.

First you need to implement your class:

 1
 2package ...;
 3
 4import com.liferay.portal.kernel.messaging.Message;
 5import com.liferay.portal.kernel.messaging.MessageListener;
 6
 7public class IndexJob implements MessageListener {
 8
 9    @Override
10    public void receive(Message arg0) {
11       
12        System.out.println("I'm Running !!!");
13
14    }
15
16}

Then you need to tell liferay to run this job. So you add the following to your liferay-portlet.xml:

 1
 2<liferay-portlet-app>
 3    <portlet>
 4        <portlet-name>Portlet</portlet-name>
 5        <icon>/icon.png</icon>
 6
 7        <scheduler-entry>
 8            <scheduler-event-listener-class>com.schedulers.IndexJob</scheduler-event-listener-class>
 9            <trigger>
10                <simple>
11                    <simple-trigger-value>1</simple-trigger-value>
12                    <time-unit>minute</time-unit>
13                </simple>
14            </trigger>
15        </scheduler-entry>
16...
17</liferay-portlet-app>

From the dtd:


<!--
The time-unit value is the unit of measure for the time specified in
property-key or simple-trigger-value. Valid values for this element are "day",
"hour", "minute", "second", or "week". The default value is "second".
-->

<!--
The simple element specifies an interval trigger for a scheduler.
-->

Note that you need an actual portlet to attach this "scheduler-entry" to. So you also need the portlet.xml:

 1
 2<portlet-app version="2.0">
 3<portlet>
 4        <portlet-name>Portlet</portlet-name>
 5        <display-name>Portlet</display-name>
 6        <portlet-class>PortletClass</portlet-class>
 7...
 8</portlet>
 9</portlet-app>


And when you deploy your portlet it will run the job at the beginning and then periodically according to the time-unit specified.

Thats all =).

Thanks again to jhf for the help.
Binh Thanh Le
RE: Liferay 6-Scheduler Engine design change...
10. Januar 2011 04:35
Antwort

Binh Thanh Le

Rang: New Member

Nachrichten: 14

Eintrittsdatum: 1. August 2010

Neue Beiträge

works like a charm, thanks very much
Than u, Miguel and thank to jhf too.
Khosro Asgharifard
RE: Liferay 6-Scheduler Engine design change...
10. Januar 2011 06:27
Antwort

Khosro Asgharifard

Rang: New Member

Nachrichten: 3

Eintrittsdatum: 29. August 2008

Neue Beiträge

Thanks for sharing.

Khosro.
gianluca maranzana
RE: Liferay 6-Scheduler Engine design change...
22. April 2011 02:56
Antwort

gianluca maranzana

Rang: Junior Member

Nachrichten: 26

Eintrittsdatum: 30. Juli 2008

Neue Beiträge

Miguel Coxo wrote: <<...So i was trying to use the scheduler in liferay and i couldn't understand the steps described here. I went to the IRC channel and jhf helped me figure out how to schedule a job in liferay 6....>>

Opened a Jira ( http://issues.liferay.com/browse/LPS-16714 ): it is (or was) not necessary to have a portlet (or separate war) to schedule a job, but in documentation of 6.0.x using of "scheduler.classes" property is still mentioned (but doesn't work for now).

G.
Neha Goel
RE: Liferay 6-Scheduler Engine design change...
27. September 2011 09:16
Antwort

Neha Goel

Rang: New Member

Nachrichten: 7

Eintrittsdatum: 22. November 2010

Neue Beiträge

Hi all,

I am facing problem with job.I made the portlet for job as suggested by you all and it runs fine on my windows machine but when I move to our server that are linux it does not run at all.

I see property in portal-ext which I dont have in my local

scheduler.enables =false


Does it matter?


PLease let me know

Regards
Neha
Jelmer Kuperus
RE: Liferay 6-Scheduler Engine design change...
27. September 2011 09:58
Antwort

Jelmer Kuperus

Rang: Liferay Legend

Nachrichten: 1192

Eintrittsdatum: 10. März 2010

Neue Beiträge

from portal.properties

#
# Set this to false to disable all scheduler classes defined in
# liferay-portlet.xml and in the property "scheduler.classes".
#
scheduler.enabled=true
Philippe CHEIPE
RE: Liferay 6-Scheduler Engine design change...
28. September 2011 00:09
Antwort

Philippe CHEIPE

Rang: Junior Member

Nachrichten: 61

Eintrittsdatum: 12. August 2010

Neue Beiträge

Yes it should solve your problem.

If it does not, verify that your job is well registered in the database: in some cases jobs are not well registered at portlet deployment.

In that case, you have to clean the database and redeploy your portlet to solve the problem.
Neha Goel
RE: Liferay 6-Scheduler Engine design change...
28. September 2011 03:33
Antwort

Neha Goel

Rang: New Member

Nachrichten: 7

Eintrittsdatum: 22. November 2010

Neue Beiträge

Thanks for your answers.I figured out that we ar eusing MS SQL and the scheduler is not getting initialised and hence it is not working .Do not know it works fine with MySQL


Regards
Neha
Ratheesh Kamoor
RE: Liferay 6-Scheduler Engine design change...
28. Februar 2012 15:05
Antwort

Ratheesh Kamoor

Rang: New Member

Nachrichten: 2

Eintrittsdatum: 31. Januar 2012

Neue Beiträge

How do I configure this scheduled batch to get hold of SpringContext. I dont want to use FileSystemContext.
I want to load the same web spring resource from WEB-INF
Cristian Serban
RE: Liferay 6-Scheduler Engine design change...
19. Juni 2012 00:47
Antwort

Cristian Serban

Rang: New Member

Nachrichten: 14

Eintrittsdatum: 5. September 2011

Neue Beiträge

hi

did you figure it out how to hold the context in the implemented Scheduler class