-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conditionnel Flow #4478
Comments
Sounds like an issue I encountered using 5.1.2 when adding a decider to a Flow - unless I'm misunderstanding how deciders should work.
The outcome of the Job when the file is present unexpectedly depends on the order in which I specify the I originally wrote the check with the NO_FILE check last: .next(fileExistsDecider)
.on(FILE_EXISTS).to(continueFlow)
.on(NO_FILE).fail()
.build(); When this is executed with no file (result NO_FILE), it behaves as expected and the job fails. Reversing the order of these Option 2. 'success condition checked last': .next(fileExistsDecider)
.on(NO_FILE).fail()
.on(FILE_EXISTS).to(continueFlow)
.build(); Now we have the fail condition checked first, and the success condition last. I would expect the order of these checks not to impact the final result of the job. |
The order of flow definition should NOT matter. If it's the case, then this is a bug in Spring Batch. Thank you for reporting this! Can you please provide a failing test or package a minimal sample that we can use to reproduce the issue? I will try to include the fix in the upcoming 5.2.0 release planned for November, otherwise it will be in a subsequent patch release. Many thanks upfront. |
Thanks @fmbenhassine. I'll put together a minimized codebase & test to illustrate. |
Hi @fmbenhassine, I've put together a set of tests with various permutations, including one that fails (test 3). |
Bug description
In Spring Batch, when defining a Flow with multiple transitions based on a JobExecutionDecider, the order of .from(decider).on(...) declarations is impacting the flow execution unexpectedly.
Environment
Steps to reproduce
Expected behavior
The flow execution decision should solely depend on the output of the JobExecutionDecider and not on the order of the .from().on() method calls in the flow definition. Each condition ("node", "can", "both") should correctly lead to its corresponding flow regardless of the order these conditions are defined in the flow builder except the * case
Minimal Complete Reproducible example
A simple setup can be provided that includes:
My flow is configured like bellow ;
Case of "node" -> OK
Case of "can" -> OK
Case of "both" -> execute always (node) (expStep).next(nodeStep).next(archiveNodeStep)
Case "*" -> OK
if i change order definition like this
Case of "node" -> KO execute always (both) .to(expStep).next(nodeStep).next(canalisationStep).next(archiveBothStep)
Case of "can" -> OK
Case of "both" -> OK
Case "*" -> OK
So I tried something else to bypass this issue by defining single flow for each case like this now so I can simplify the decider flow ...
The text was updated successfully, but these errors were encountered: