Announcement Announcement Module
Collapse
No announcement yet.
How to shutdown the Quarz scheduler when the application in app server stops Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to shutdown the Quarz scheduler when the application in app server stops

    Hi,

    I had a situation. I configured the Spring Batch to my Enterprise application. I deployed it in Websphere app server. As long as the server starts, the load on init servlet calls the Quarzlauncher.java(my local class which internally configured using quartz-job-launcher-context.xml). And schedules each 25 mins. When I stop the application in the app server, the quartz job still running. i.e its triggering the job still at each 25 mins. How to shut down the quartz when I stop the application?

    If anybody know how to shutdown the quartz scheduler, Please give me the solution?


    Thanks,
    Sundar

  • #2
    This is more of Quartz related question, you can issue the following code to shutdown your scheduler:

    scheduler.shutdown();

    Depending upon the application server you use, there should be some event you can listen to when the server shuts down.... and there you can lookup for your scheduler and shut it down. Hope that was helpful!!!

    Comment


    • #3
      How did you configure to run spring bacthes in app server?

      Hi sundar,
      Can you please let me know how to run spring batches though web interface(when the user clicks a start button).
      I am able to run simple batch presses(hello world-taskelets) from command line
      (using parameters:
      mvn exec:java -Dexec.mainClass=org.springframework.batch.core.lau nch.support.CommandLineJobRunner -Dexec.args="simpleJob.xml simpleJob")
      How can I configure to run those tasklets in Spring Controller classes(with out maven)
      TIA
      Shivaji

      1------------------------Here is my context file: ---------------
      ...
      <import resource="myAapplicationContext.xml"/>

      <!-- ...............tasklet ...................... -->

      <bean id="hello" class="com.MyPrintTasklet">
      <property name="message" value="Hello--oo"/>
      </bean>

      <bean id="space" class="com.MyPrintTasklet">
      <property name="message" value=" "/>
      </bean>

      <bean id="world" class="com.MyPrintTasklet">
      <property name="message" value="Universe-e"/>
      </bean>



      <!-- ...............tasklet steps ......................... -->

      <bean id="taskletStep" abstract="true"
      class="org.springframework.batch.core.step.tasklet .TaskletStep">
      <property name="jobRepository" ref="jobRepository"/>
      </bean>

      <!-- ...............simpleJob ......................... -->

      <bean id="simpleJob" class="org.springframework.batch.core.job.SimpleJo b">
      <property name="name" value="simpleJob" />
      <property name="steps">
      <list>
      <bean parent="taskletStep">
      <property name="tasklet" ref="hello"/>
      </bean>
      <bean parent="taskletStep">
      <property name="tasklet" ref="space"/>
      </bean>
      <bean parent="taskletStep">
      <property name="tasklet" ref="world"/>
      </bean>
      </list>
      </property>
      <property name="jobRepository" ref="jobRepository"/>
      </bean>

      </beans>

      2-----------------------Tasklet Job---------
      public class MyPrintTasklet implements Job {

      public void execute(JobExecutionContext arg0) throws JobExecutionException{

      System.out.println(".....Task Three Job....: " + new Date() + " hashcode:" + this.hashCode());
      }
      }

      Comment


      • #4
        Originally posted by shivaji View Post
        Hi sundar,
        Can you please let me know how to run spring batches though web interface(when the user clicks a start button).
        4.4.2. Running Jobs from within a web container

        You can do something as simple as wire a JobLauncher & the Job into your controller and executing it from there or get a littler fancier by leveraging a JobRegistry to get the Job by name or start the job from a JobOperator.

        Comment

        Working...
        X