Spring Package - STEP Duplicate Message

I have a spring batch job that is expected to handle the "N" job jobs sequentially based on FIFO. There are 5 steps to this spring batch job.
We use DECIDER to determine any other job identifier. If so, go to the first step and run all the steps for this job ID.
I see the message "duplicate step" in the log issued by spring-batch, which looks fine until the step in the first job (for example, job-id = 1) gets UNKNOWN status. In this case, the same step for the second job (job-id = 2) cannot begin with the message "The step is in the UNKNOWN state, restart ...". Is there a better approach for defining spring-batch jobs to handle "N" job jobs.

There is a table that contains information about the task. Each job places orders in the order table. It is possible that on the same day it is necessary to process two works. The task can insert / update the same order number that has the same revision (with a difference in other details) or a different version of the same order number. The batch program should process these jobs in the FIFO model based on success_time in the job table.

Assume the table structure is below

Job_Id job_name success_time
1 job1 2014-09-29 10:00:00
2 job2 2014-09-29 13:00:00

Order_id order_number order_revision order_details job_id
1 ABC 1 Test1 1
2 XYZ 1 Test2 1
3 ABC 2 Test1-Rev2 2

An example configuration is shown below. For brevity, I deleted the metadata definitions and reused the reader and writer.

<batch:step id="abstractParentStep" abstract="true">
    <batch:tasklet>
        <batch:chunk commit-interval="100" />
    </batch:tasklet>
</batch:step>

<-- Using same reader and writer to simplify scenario depiction --> 
<batch:job id="OrderProcessingJob">
    <batch:step id="Collect-Statistics-From-Staging-Tables" next="Validate-Order-Mandatory-Fields" parent="abstractParentStep">
        <batch:tasklet>
            <batch:chunk reader="orderReader" writer="orderWriter" />
        </batch:tasklet>
    </batch:step>
    <batch:step id="Validate-Order-Mandatory-Fields" next="Validate-Item-Mandatory-Fields" parent="abstractParentStep">
        <batch:tasklet>
            <batch:chunk reader="orderReader" writer="orderWriter" />
        </batch:tasklet>
    </batch:step>
    <batch:step id="Validate-Item-Mandatory-Fields" next="decision" parent="abstractParentStep">
        <batch:tasklet>
            <batch:chunk reader="orderReader" writer="orderWriter" />
        </batch:tasklet>
    </batch:step>
    <batch:decision id="decision" decider="processMoreJobsDecider">
        <batch:next on="REPEAT" to="Validate-Order-Mandatory-Fields" />
        <batch:end on="COMPLETED" />
    </batch:decision>

</batch:job>

In the first step, we check how many work orders (quantity) need to be processed and places them in the ExecutionContext. In the decisive case, we check whether the total number of processed jobs matches the counter and returns the REPEAT status if there are more worker_processes to process.

We encountered an exception, as mentioned above, when the first step of the job remained in the UNKNOWN state and the second job (because the receiver decided that another job_id to process) received an exception message, as shown above.

+4
source share
2 answers

. , .

, partitionedSimple.groovy ( , groovy <filename.groovy>). step1 , ( hardcoded to 3) ( , ). partitionedStep, 3 . repeatedStep:<partition name>. partitionIndex , , .

, 2. :

Status is: FAILED
Step executions: 
  1: step1 
  2: partitionedStep FAILED
  4: repeatedStep:partition_1 
  5: repeatedStep:partition_2 FAILED
  3: repeatedStep:partition_3 

, :

Status is: COMPLETED
Step executions: 
  6: partitionedStep 
  null: repeatedStep:partition_1 STARTING
  7: repeatedStep:partition_2 
  null: repeatedStep:partition_3 STARTING

, - - , , .

. , , (allowStartIfComplete) . bean. , job() bean factory , "" . , . :

Step executions: 
  1: step1 
  2: wrappingStep 
  3: repeated-1 
  4: wrappingStep FAILED
  5: repeated-2 FAILED

( repeated-3 )

:

Step executions: 
  6: wrappingStep 
  7: wrappingStep 
  8: repeated-2 
  9: wrappingStep 
  10: repeated-3
+1

, "next" .

Java, XML, ( ):

@Bean
public Flow insertGbDatabaseRecordsFlow(final Step populateFpSettlementsStep, final Step populateGbDatabaseStep) {
    FlowBuilder<Flow> flowBuilder = new FlowBuilder<>("insertGbDatabaseRecordsFlow");
    flowBuilder.next(populateFpSettlementsStep);
    flowBuilder.next(populateGbDatabaseStep);
    return flowBuilder.build();
}

→ start

@Bean
public Flow insertGbDatabaseRecordsFlow(final Step populateFpSettlementsStep, final Step populateGbDatabaseStep) {
    FlowBuilder<Flow> flowBuilder = new FlowBuilder<>("insertGbDatabaseRecordsFlow");
    flowBuilder.start(populateFpSettlementsStep);
    flowBuilder.next(populateGbDatabaseStep);
    return flowBuilder.build();
}

Spring Batch xml config.

0

All Articles