Could you please review the attached patch?
With the patch, if an async service fails, the status of its JobSandbox
record is set to "failed" even if the service will not be rescheduled.
It seems to work fine, can I commit it?
Jacopo
Jacopo Cappellato wrote:
I'm not completely sure, but it seems to me that the jobs in the
JobSandbox entity (i.e. service jobs submitted with an runAsync call),
always end their life in the "Finished" status, even if the service
returned an error.
Is it possible? Is this by design or there is a bug somewhere and they
should be moved to the "Failed" or "Crashed" status?
Jacopo
Index: framework/service/src/org/ofbiz/service/job/PersistedServiceJob.java
===================================================================
--- framework/service/src/org/ofbiz/service/job/PersistedServiceJob.java
(revisione 523166)
+++ framework/service/src/org/ofbiz/service/job/PersistedServiceJob.java
(copia locale)
@@ -185,6 +185,7 @@
protected void failed(Throwable t) throws InvalidJobException {
super.failed(t);
+ GenericValue job = getJob();
// if the job has not been re-scheduled; we need to re-schedule and
run again
if (nextRecurrence == -1) {
if (this.canRetry()) {
@@ -193,25 +194,24 @@
cal.setTime(new Date());
cal.add(Calendar.MINUTE,
ServiceConfigUtil.getFailedRetryMin());
long next = cal.getTimeInMillis();
- GenericValue job = getJob();
try {
createRecurrence(job, next);
} catch (GenericEntityException gee) {
Debug.logError(gee, "ERROR: Unable to re-schedule job [" +
getJobId() + "] to re-run : " + job, module);
}
-
- // set the failed status
- job.set("statusId", "SERVICE_FAILED");
- try {
- job.store();
- } catch (GenericEntityException e) {
- Debug.logError(e, "Cannot update the job sandbox", module);
- }
Debug.log("Persisted Job [" + getJobId() + "] Failed
Re-Scheduling : " + next, module);
} else {
Debug.logWarning("Persisted Job [" + getJobId() + "] Failed -
Max Retry Hit; not re-scheduling", module);
}
}
+ // set the failed status
+ job.set("statusId", "SERVICE_FAILED");
+ job.set("finishDateTime", UtilDateTime.nowTimestamp());
+ try {
+ job.store();
+ } catch (GenericEntityException e) {
+ Debug.logError(e, "Cannot update the job sandbox", module);
+ }
}
/**