-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Add JobParametersIncrementer implementation based on a DataFieldMaxValueIncrementer #1521
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
Comments
Michael Minella commented Can you create this as a pull request on Github? Please be sure to add a unit test for your component and fill out the contributor's license agreement if you have not already. If you have any questions about submitting a pull request, you can read more about it here: https://github.com/SpringSource/spring-integration/blob/master/CONTRIBUTING.md |
Gregory D. Hopkins commented If at home, I would have gone the GitHub route... My enterprise group has GitHub blocked. :( Thanks! |
Gregory D. Hopkins commented By the way, any comment on the StackOverflow Q? |
Michael Minella commented In what you have in the StackOverflow question, I don't see anything obvious. You say that you are 100% sure that you are not accidentally kicking off the same job multiple times at once? If you have a test case that can reproduce the issue, I'd be more than happy to dig a bit deeper... |
Alexis SOUMAGNE commented I've already implemented something similar here : https://github.com/almex/Raildelays/blob/master/batch/src/main/java/org/springframework/batch/core/JobParametersSequenceIncrementer.java If you're interested I can create a pull request. |
Michael Minella commented Moving this to 4.2 since we need a test written. |
Mahmoud Ben Hassine commented @Gregory D. Hopkins Can you open a PR on github with the attached file? It would be great if you add a test too. We will review it on github and consider merging it for v4.2. Thank you upfront. |
I polished the attached file and added a test (see a333c16). For future reference, here is a summary of the cases where the new 1. Un-ordered database sequencesSome database providers do not guarantee the order of numbers generated by sequences (like Oracle where NOORDER is the default). This means job instance IDs generated by
In this example, when creating the job instance 2, Spring Batch will calculate the last instance (ie 23) and pass its 2. Concurrent access to the incrementerThe job parameters incrementer might be called concurrently when:
In these cases, those threads/processes might end-up with the same set of next parameters returned by the incrementer (since they might calculate the same last instance and pass its parameters to the incrementer). This leads to a |
Gregory D. Hopkins opened BATCH-2074 and commented
Due to problems listed in the linked StackOverflow Q, I created an implementation of
org.springframework.batch.core.JobParametersIncrementer
based on Spring JDBC'sorg.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer
.It looks like
org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer
is used several places in the Spring Batch project, but I could not find any that provided linkage toorg.springframework.batch.core.JobParametersIncrementer
.Hopefully, others will find this useful.
Reference URL: http://stackoverflow.com/questions/17975917/spring-batch-runidincrementer-not-generating-next-value
Attachments:
1 votes, 4 watchers
The text was updated successfully, but these errors were encountered: