Author: nmalin
Date: Tue Sep 11 07:42:19 2018 New Revision: 1840526 URL: http://svn.apache.org/viewvc?rev=1840526&view=rev Log: Improved: Async persist service on error no restart by default (OFBIZ-10557) Related to the discussion on dev [1] I turn off by default the indefinitely restart when a service async failed. When a service run by async with persistence (eg: dispatcher.runAsync('returnErrorService', context, true)), the default value set on jobsandbox.maxRetry is now 0 instead of -1 before. If you want run indefinitely an async service while isn't a success, set on your service definition max-retry='-1'. [1] https://s.apache.org/EBhf Modified: ofbiz/ofbiz-framework/trunk/framework/service/dtd/services.xsd ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelService.java ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelServiceReader.java ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/job/PersistedServiceJob.java Modified: ofbiz/ofbiz-framework/trunk/framework/service/dtd/services.xsd URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/dtd/services.xsd?rev=1840526&r1=1840525&r2=1840526&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/service/dtd/services.xsd (original) +++ ofbiz/ofbiz-framework/trunk/framework/service/dtd/services.xsd Tue Sep 11 07:42:19 2018 @@ -140,7 +140,7 @@ under the License. </xs:documentation> </xs:annotation> </xs:attribute> - <xs:attribute name="max-retry" type="xs:int" default="-1"/> + <xs:attribute name="max-retry" type="xs:int" default="0"/> <xs:attribute name="debug" default="false"> <xs:simpleType> <xs:restriction base="xs:token"> Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelService.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelService.java?rev=1840526&r1=1840525&r2=1840526&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelService.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelService.java Tue Sep 11 07:42:19 2018 @@ -161,7 +161,7 @@ public class ModelService extends Abstra public int transactionTimeout; /** Sets the max number of times this service will retry when failed (persisted async only) */ - public int maxRetry = -1; + public int maxRetry = 0; /** Permission service name */ public String permissionServiceName; Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelServiceReader.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelServiceReader.java?rev=1840526&r1=1840525&r2=1840526&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelServiceReader.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ModelServiceReader.java Tue Sep 11 07:42:19 2018 @@ -213,13 +213,13 @@ public class ModelServiceReader implemen // set the max retry field String maxRetryStr = UtilXml.checkEmpty(serviceElement.getAttribute("max-retry")); - int maxRetry = -1; + int maxRetry = 0; if (UtilValidate.isNotEmpty(maxRetryStr)) { try { maxRetry = Integer.parseInt(maxRetryStr); } catch (NumberFormatException e) { - Debug.logWarning(e, "Setting maxRetry to -1 (default)", module); - maxRetry = -1; + Debug.logWarning(e, "Setting maxRetry to 0 (default)", module); + maxRetry = 0; } } service.maxRetry = maxRetry; Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/job/PersistedServiceJob.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/job/PersistedServiceJob.java?rev=1840526&r1=1840525&r2=1840526&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/job/PersistedServiceJob.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/job/PersistedServiceJob.java Tue Sep 11 07:42:19 2018 @@ -80,7 +80,7 @@ public class PersistedServiceJob extends this.jobValue = jobValue; Timestamp storedDate = jobValue.getTimestamp("runTime"); this.startTime = storedDate.getTime(); - this.maxRetry = jobValue.get("maxRetry") != null ? jobValue.getLong("maxRetry") : -1; + this.maxRetry = jobValue.get("maxRetry") != null ? jobValue.getLong("maxRetry") : 0; Long retryCount = jobValue.getLong("currentRetryCount"); if (retryCount != null) { this.currentRetryCount = retryCount; |
Free forum by Nabble | Edit this page |