Skip step based on job parameter

justify

I've read through the spring batch docs a few times and searched for a way to skip a job step based on job parameters.

For example say I have this job

<batch:job id="job" restartable="true"
        xmlns="http://www.springframework.org/schema/batch">
        <batch:step id="step1-partitioned-export-master">
            <batch:partition handler="partitionHandler"
                partitioner="partitioner" />
            <batch:next on="COMPLETED" to="step2-join" />
        </batch:step>
        <batch:step id="step2-join">
            <batch:tasklet>
                <batch:chunk reader="xmlMultiResourceReader" writer="joinXmlItemWriter"
                    commit-interval="1000">
                </batch:chunk>
            </batch:tasklet>
            <batch:next on="COMPLETED" to="step3-zipFile" />
        </batch:step>
        <batch:step id="step3-zipFile">
            <batch:tasklet ref="zipFileTasklet" />
            <!-- <batch:next on="COMPLETED" to="step4-fileCleanUp" /> -->
        </batch:step>
        <!-- <batch:step id="step4-fileCleanUp">
            <batch:tasklet ref="fileCleanUpTasklet" />
        </batch:step> -->
    </batch:job>

I want to be able to skip step4 if desired by specifying in the job paramaters.

The only somewhat related question I could find was how to select which spring batch job to run based on application argument - spring boot java config

Which seems to indicate that 2 distinct job contexts should be created and the decision made outside the batch step definition.

I have already followed this pattern, since I had a csv export as well as xml as in the example. I split the 2 jobs into to separate spring-context.xml files one for each export type, even though the there where not many differences.

At that point I though it was perhaps cleaner since I could find no examples of alternatives.

But having to create 4 separate context files just to make it possible to include step 4 or not for each export case seems a bit crazy.

I must be missing something here.

Hansjoerg Wingeier

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Skip step based on job parameter

From Dev

Spring Batch accessing job parameter inside step

From Dev

Optional promise-step based on query parameter

From Dev

Execute Build Step Based On Parameter Value

From Dev

Execute Build Step Based On Parameter Value

From Java

How to write conditional step with boolean parameter in jenkins scripted pipeline job?

From Dev

Skip a behave step in the step implementation

From Dev

CasperJS skip step on timeout

From Dev

Dummy step is not work in Job

From Dev

Add parameter to job context from tasklet step and use in later steps in Spring Batch

From Dev

Skip step in personal builds in TeamCity

From Dev

Skip Checkout Step but make associations

From Dev

skip generic parameter on demand

From Dev

Cloudant skip parameter not working

From Dev

Skip parameter in Linux bash

From Dev

Cloudant skip parameter not working

From Dev

Skip a default parameter in D

From Dev

Octave skip parameter

From Dev

Zapier: How to skip a step in multi-step zaps

From Dev

Skip confirmation step with MicrosoftBot's FormBuilder

From Dev

Is is possible to skip the confirmation step while adding a repository?

From Dev

Is is possible to skip the confirmation step while adding a repository?

From Dev

Batch file, skip a step if an error occurs

From Dev

Jenkins - Is this possible? Have more than one Build button for a parameter based job

From Dev

Passing stream to job as parameter

From Dev

Skip notify-send job if screen locked?

From Dev

Hadoop - How Job executed - Need step by step explaination

From Dev

How to skip a job in Jenkins if another job is in the failed state

From Dev

"Step" or "Job" Scope for Spring-Batch beans?

Related Related

HotTag

Archive