Comments (8)
Job listeners are part of the job execution, so if one of the listeners afterJob() fails, the whole job would still fail. We cannot be sure a job is fully complete and hence don't assign a endTime till all job listeners are done with afterJob().
By looking at StepExecutionRunner, I see the logic is consistent w/ JobExecutionRunner, though I haven't tested it.
from jsr352.
Point 9.2.1 of the Spec says the following "A job listener receives control before and after a job execution runs". This is a little bit vague but the JavaDoc comment a few lines later is more precise: "The afterJob method receives control after the job execution ends."
Same thing for StepListeners "The afterStep method receives control after a step execution ends. " Point 9.2.2 of the Spec.
Doesn't "after the execution ends" mean, that the execution has ended at this point and therefore an exit status and endTime should be available? When an execution has ended, should/could a listener make a job fail?
from jsr352.
An old spec bug related to this issue:
Bug 4385 - Spec must specify the effect of throwing Exceptions from Listeners
Excerpt from spec 1.0-rev_A:
8.1.2 Job Level Exception Handling
Any unhandled exception thrown by a job-level listener causes the job to terminate with a batch status of FAILED. In this context, "unhandled" simply means an exception thrown by the listener back to the runtime implementation.
from jsr352.
Batch spec discussion on when job execution end time is available (March 2015):
https://java.net/projects/jbatch/lists/public/archive/2015-03/message/0
from jsr352.
Saw that also. But it only says, that the endTime is null, as long as the job is not completed, stopped or failed.
According to Bug 4385 they clarified that an exception inside a listener makes a job having the status failed. The question which status the job has, when JobListener#afterJob() is called an no exception has been thrown is in my opinion not answered by the Spec.
I filed this bug now: https://java.net/bugzilla/show_bug.cgi?id=6975
from jsr352.
... but reading again through point 8.7 I come to the following conclusion:
"Status COMPLETED - Batch job has ended normally ....." .... "A job execution will end under the following conditions: 1. A job-level execution element (step, flow, or split) finishes execution, without specifying a "next" attribute and without the exit status matching any transition elements. In this case, the batch status is set to COMPLETED."
And the JavaDoc of JobListener#afterJob() says: "The afterJob method receives control after the job execution ends. "
Doesn't that mean the following?:
- a Job finishes execution after the last step
- a finished job is given the status completed
- JobLister#afterJob() methods are called?
from jsr352.
We can optimistically set batch status to COMPLETED after all steps and other job elements complete successfully, before calling job listeners afterJob(), to make it more consistent, even though the final job batch status may be FAILED, if afterJob() throws exception.
Before that is in place, a workaround is to end your job with a that contains a
<decision id="decision1" ref="xxx.Decider1">
<end on="*"/>
</decision>
from jsr352.
I suggest to wait for a response to the bug I filed on java.net before changing anyting. The decision-element is a neat trick. It also works with an element directly inside the last step.
from jsr352.
Related Issues (20)
- Enable Support to get DB Username/Password from enivonment variable for jberet.properties HOT 5
- Fix the random test failures on ubuntu HOT 3
- disable Caucho and PHP script tests
- Fix the random test failure of `purgeInMemoryRepository`
- fix the random test failure: `jobExecutionIdFromIncludeRunningOnes`
- Write a blog post for the new feature: Enable Support to get DB Username/Password from environment variable for `jberet.properties` HOT 1
- Add a `layer-spec` similar to the ones in `resteasy-spring` HOT 3
- Add deployment tests into the project by using the provisioned WildFly server with the update-to-date project module(by using Galleon `feature-pack` or WildFly Channel).
- Upgrade to use JUnit 5
- jberet-core logging database credentials
- jberet.properties: extract other database configuration from environment variables
- Upgrade `jakarta.annotation` API version for the next major release.
- Add WildFly Preview CI Testing.
- Add `version.org.wildfly.plugins.wildfly-maven-plugin` for overriding.
- Remove the dependency of `jakarta.persistence-api`
- Remove the dependency of the `validation-api`
- Consider dropping guava HOT 4
- JdbcRepository doesn't override getJob, jobExists, getJobNames HOT 5
- Support @BatchProperty of type Enum HOT 1
- Use same Springbatch schema HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jsr352.