Announcement Announcement Module
Collapse
No announcement yet.
Retrieving Job Parameters for a Job? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Retrieving Job Parameters for a Job?

    Hi,
    I would like to restart the job if the job failed in its previous execution. To do that, i need to know what was the job parameter i passed earlier so that i can pass the same parameters this time as well. How do i retrieve the job parameters for a given job name?.

    Basically i am checking the status of the job before launching.
    If the status is failed, i want to restart the job so that it would start from where it left. If the status is completed, i want to create a new job instance and would start from beginning. I am using quartz and i am going to do this QuartzJobBean.

    thanks in advance,
    Ramkris

  • #2
    There is no easy way to query for parameters given a job name.

    The parameters are what identifies a job instance - what makes you "forget" the parameter values? If you want to ask the framework to restart a job instance you certainly need to tell which one - I think you generally shouldn't need the framework to tell you what options for restart you have given a job name.

    Comment


    • #3
      On the other hand I imagine the functionality will be needed to build operational support for the framework - e.g. a webapp that gives overview of the history of job runs and allows the user restart a job by clicking a button.

      Such application shouldn't really "understand" the database tables, it should just ask the JobRepository for information it needs - so maybe we should provide such features...
      Last edited by robert.kasanicky; Apr 22nd, 2008, 09:46 AM.

      Comment


      • #4
        OK. Then what needs to be done to achieve my following requirement?
        Basically i am checking the status of the job before launching.
        If the status is failed, i want to restart the job so that it would start from where it left. If the status is completed, i want to create a new job instance and would start from beginning. I am using quartz and i am going to do this QuartzJobBean.
        Also i don't want to restart the job as soon as it failed. I want to restart only at the time of next scheduled execution or through the UI invocation.

        Comment


        • #5
          So you will need to store just enough information you need to recreate the parameters somewhere yourself or you can query the framework's database that already contains the information you need.

          Comment


          • #6
            If your job is launched from a Quartz there's no way you can "forget" the job parameters (they must be configured somewhere). You can tell if a job instance was already launched sucessfully by trying to launch it again and catching JobInstanceAlreadyCompleteException, or at a lower level you can simply use the JobRepository to get the same exception from createJobExecution.

            To visualise the job parameters in a UI is a different problem entirely (and out of scope for Spring Batch). We plan to build some monitoring and management features, but they would most likely not be in the open source product.

            Comment

            Working...
            X