Announcement Announcement Module
Collapse
No announcement yet.
Scheduling in Cluster Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment


    • #3
      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

      Comment


      • #4
        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.

        Comment


        • #5
          He cannot change the table, but he didn't say that he cannot add a table.

          Comment


          • #6
            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?

            Comment


            • #7
              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.

              Comment


              • #8
                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.

                Comment

                Working...
                X