You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by Jacopo Cappellato <ti...@sastau.it> on 2007/04/04 10:39:11 UTC

Re: Questions about error status of the jobs in JobSandbox

Hi Andy,

what do you think? can I commit it?

Jacopo

David E. Jones wrote:
> 
> I think it's a good idea, it is more informative and accurate than 
> "Finished".
> 
> Andrew Zeneski would know better if it will have any side effects or not.
> 
> -David
> 
> 
> On Mar 31, 2007, at 6:13 AM, Jacopo Cappellato wrote:
> 
>> 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);
>> +        }
>>      }
>>
>>      /**
> 



Re: Questions about error status of the jobs in JobSandbox

Posted by Jacopo Cappellato <ti...@sastau.it>.
This is now committed in rev. 525721
If you see something wrong with it, let me know and I'll revert it.

Jacopo


Jacopo Cappellato wrote:
> Hi Andy,
> 
> what do you think? can I commit it?
> 
> Jacopo
> 
> David E. Jones wrote:
>>
>> I think it's a good idea, it is more informative and accurate than 
>> "Finished".
>>
>> Andrew Zeneski would know better if it will have any side effects or not.
>>
>> -David
>>
>>
>> On Mar 31, 2007, at 6:13 AM, Jacopo Cappellato wrote:
>>
>>> 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);
>>> +        }
>>>      }
>>>
>>>      /**
>>
>