Announcement Announcement Module
Collapse
No announcement yet.
Only one JobInstance corresponding Job can be running at a given time ? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Only one JobInstance corresponding Job can be running at a given time ?

    Is this really the case in Spring Batch?

    Wat if I want to start a JobInstance of a Job every hour, but it takes two hours for each JobInstance to finish its execution.

    When I start the JobInstance at 2 P.M, the JobInstance of 1 P.M. will still be running. So occurding to the statement this second JobInstance can start.
    Is it not possible to have JobInstances of the same Job running at the same time ?

  • #2
    http://static.springframework.org/sp...ml#jobInstance

    Comment


    • #3
      Dave,

      It was after reading this document that I posed myself this question.
      So is there a way to solve the problem of the hourly job that has an execution time of two hours. You could solve this by duplicating the job, but is there another way to solve this ?

      Comment


      • #4
        I don't understand what the problem is. You launch the job every hour. If it is a new instance, then use new parameters (or a JobParametersIncrementer to do it for you). The JobOperator even has a method startNext() that wraps all this for you.

        Comment


        • #5
          The documentation says :
          Therefore, each JobInstance can have multiple executions (JobExecution is discussed in more detail below) and only one JobInstance corresponding to a particular Job can be running at a given time.
          So I launch a Job every hour, using different parameters.
          But if a JobInstance takes 120 minutes to finish and I launch a Job at 1P.M and one at 2P.M that makes two JobInstances corresponding to a particular Job can be running at a given time. (The 1 and 2 P.M JobsInstance)

          However the documentation says such a thing is not possible!
          Does this clarify my question?

          Comment


          • #6
            Sorry, the user guide isn't crystal clear there, but it is actually accurate, since a JobInstance includes the JobParameters. I can change that section to read

            ...only one JobInstance corresponding to a particular Job and JobParameters can be running at a given time.
            If you read on a little further it already says

            Using a new JobInstance will mean 'start from the beginning' and using an existing instance will generally mean 'start from where you left off.'
            and the example a little later in the section entitled "JobExecution" clarifies further (and actually has two executions for the same Job running concurrently). Hopefully that is clearer now.

            Comment


            • #7
              On the same note, is it possible to configure Spring Batch in order to only allow 1 job of a given job type to be executing at any given time , regardless off the JobParameters passed in.

              My reason for asking is that I have a job that can be run on a per province (JobParameter) basis. But I really don't want 2 jobs for different provinces running at the same time as they can cause some db deadlock etc.

              Comment


              • #8
                Spring Batch doesn't currently provide that feature, no. Seems like a runtime / scheduling, concern, so tools that provide those features are needed, e.g. it will probably be available in the SpringSource Enterprise Batch product.

                Comment


                • #9
                  Any ETA on the Enterprise version?

                  Comment

                  Working...
                  X