Results 1 to 8 of 8

Thread: Scheduling in Cluster

  1. #1
    Join Date
    Nov 2007
    Posts
    5

    Default Scheduling in Cluster

    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?

    Code:
    <bean id="simpleReportTrigger"
    		class="org.springframework.scheduling.quartz.CronTriggerBean">
    		<property name="jobDetail">
    			<ref bean="dealFeedGeneration" />
    		</property>
    		<property name="cronExpression">
    			<value>${scheduleTime}</value>
    		</property>
    	</bean>
    
    	<bean id="dealFeedGeneration"
    		class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
    		<property name="targetObject">
    			<ref bean="feedTaskGenerator" />
    		</property>
    		<property name="targetMethod">
    			<value>getDealFeedList</value>
    		</property>
    	</bean>
    <bean
    		class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
    		<property name="triggers">
    			<list>
    				<ref bean="simpleReportTrigger" />
    			</list>
    		</property>
    	</bean>

  2. #2
    Join Date
    Dec 2006
    Posts
    1,061

    Default

    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.

  3. #3
    Join Date
    Nov 2007
    Posts
    5

    Default

    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

  4. #4
    Join Date
    Dec 2006
    Posts
    1,061

    Default

    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.

  5. #5
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    He cannot change the table, but he didn't say that he cannot add a table.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  6. #6
    Join Date
    Dec 2006
    Posts
    1,061

    Default

    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?

  7. #7
    Join Date
    Nov 2007
    Posts
    5

    Default

    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.

  8. #8
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    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.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •