View Full Version : Scheduling in Cluster
BSShan
Nov 6th, 2007, 11:50 PM
I am using quartz for scheduling purpose. When application is deployed in weblogic cluster environment, the entire server initiates the process. I don’t have DB operation, so that can use select for update query to lock the table and be sure that only one server starts the process. I have file writing operation. Is there any way to configure the quartz to initiates only once?
<bean id="simpleReportTrigger"
class="org.springframework.scheduling.quartz.CronTriggerB ean">
<property name="jobDetail">
<ref bean="dealFeedGeneration" />
</property>
<property name="cronExpression">
<value>${scheduleTime}</value>
</property>
</bean>
<bean id="dealFeedGeneration"
class="org.springframework.scheduling.quartz.MethodInvoki ngJobDetailFactoryBean">
<property name="targetObject">
<ref bean="feedTaskGenerator" />
</property>
<property name="targetMethod">
<value>getDealFeedList</value>
</property>
</bean>
<bean
class="org.springframework.scheduling.quartz.SchedulerFac toryBean">
<property name="triggers">
<list>
<ref bean="simpleReportTrigger" />
</list>
</property>
</bean>
lucasward
Nov 7th, 2007, 11:04 AM
I'm not sure I fully understand the question. By initiate, are you referring to the Quart servlet listener that will create a scheduler? And what do you mean by only once? Once per server, or once total? Keep in mind that even if you have say, one quartz scheduler per server, you can use Quartz' clustering features to ensure that only one scheduler kicks off a job. However, this has the unfortunate side effect of requiring your job schedule to be in the database.
BSShan
Nov 12th, 2007, 07:57 AM
I need one scheduler kicks off a job. Can you give me the configuration Quartz' clustering feature.
My Requirement is to get all the data from one table and write in to the file. I can't change the table to add or delete one more column. Since the application is deployed in cluster env, all the servers kicks off the process and there is a possibility the file is overwritten. I need to avoid this situation and make sure that only one server kicks off the process
Thanks in advance
lucasward
Nov 14th, 2007, 02:30 PM
It is my understanding that you cannot use any clustering features of Quartz without using the database as a JobStore. I have heard that later features will remove this requirement, but for now that seems to be the only option. If you can't add support for a database job store, then I think you will have to code your own solution. This could be implemented using the JobLauncher interface. If JobLauncher.isRunning() returns false, call start, if not let that thread finish.
Marten Deinum
Nov 14th, 2007, 02:52 PM
He cannot change the table, but he didn't say that he cannot add a table.
lucasward
Nov 14th, 2007, 03:44 PM
I assumed he couldn't use a Quart database Job Store, but would still be able to hit the database. BSShaun, is this the case?
BSShan
Nov 15th, 2007, 10:31 AM
Thanks for your response
Could you please explain both the methods
1. Do i need to create a table to control the scheduling process. Can it be controlled by xml configuraion itself. How that table controls the process
2. If i need to use JobLauncher interface, Can't i use MethodInvokingJobDetailFactoryBean to invoke my method at schedule time.
Could you please give me a link which explains configuration / coding changes. I am not aware of this concept.
Marten Deinum
Nov 15th, 2007, 10:55 AM
The table is needed as a central location to store the fact that a job already started. Configurationc an still be in xml, it is simply the state of the job that is stored.
Question 2 yeah sure you can, but the fact/issue with that is if you do that in a cluster of 4 machines 4 jobs are scheduled... And that is something you don't want.
vBulletin® v3.7.3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.