[jbpm-commits] JBoss JBPM SVN: r6357 - in jbpm3/branches/jbpm-3.2-soa/modules: core/src/main/java/org/jbpm/job/executor and 2 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Mon May 17 23:14:15 EDT 2010
Author: alex.guizar at jboss.com
Date: 2010-05-17 23:14:14 -0400 (Mon, 17 May 2010)
New Revision: 6357
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/CleanUpProcessJob.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/ExecuteActionJob.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/ExecuteNodeJob.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/Job.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/Timer.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/executor/JobExecutor.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml
jbpm3/branches/jbpm-3.2-soa/modules/userguide/src/main/docbook/en/modules/configuration.xml
Log:
JBPM-2861: make job retries setting available to message and timer services other than the job executor
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/CleanUpProcessJob.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/CleanUpProcessJob.java 2010-05-17 23:34:36 UTC (rev 6356)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/CleanUpProcessJob.java 2010-05-18 03:14:14 UTC (rev 6357)
@@ -42,14 +42,14 @@
public boolean execute(JbpmContext jbpmContext) throws Exception {
SchedulerService schedulerService = jbpmContext.getServices().getSchedulerService();
- if (schedulerService!=null) {
- schedulerService.deleteTimersByProcessInstance(processInstance);
+ if (schedulerService != null) {
+ schedulerService.deleteTimersByProcessInstance(getProcessInstance());
}
return true;
}
public String toString() {
- return "CleanUpProcessJob(" + id + ',' + processInstance + ')';
+ return "CleanUpProcessJob(" + getId() + ',' + getProcessInstance() + ')';
}
}
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/ExecuteActionJob.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/ExecuteActionJob.java 2010-05-17 23:34:36 UTC (rev 6356)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/ExecuteActionJob.java 2010-05-18 03:14:14 UTC (rev 6357)
@@ -10,7 +10,7 @@
private static final long serialVersionUID = 1L;
- Action action;
+ private Action action;
public ExecuteActionJob() {
}
@@ -20,6 +20,7 @@
}
public boolean execute(JbpmContext jbpmContext) throws Exception {
+ Token token = getToken();
ExecutionContext executionContext = new ExecutionContext(token);
executionContext.setAction(action);
executionContext.setEvent(action.getEvent());
@@ -35,7 +36,7 @@
}
public String toString() {
- return "ExecuteActionJob(" + id + ',' + action + ')';
+ return "ExecuteActionJob(" + getId() + ',' + action + ')';
}
public Action getAction() {
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/ExecuteNodeJob.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/ExecuteNodeJob.java 2010-05-17 23:34:36 UTC (rev 6356)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/ExecuteNodeJob.java 2010-05-18 03:14:14 UTC (rev 6357)
@@ -19,14 +19,15 @@
}
public boolean execute(JbpmContext jbpmContext) throws Exception {
- token.unlock(this.toString());
+ Token token = getToken();
+ token.unlock(toString());
ExecutionContext executionContext = new ExecutionContext(token);
node.execute(executionContext);
return true;
}
public String toString() {
- return "ExecuteNodeJob(" + id + ',' + node + ')';
+ return "ExecuteNodeJob(" + getId() + ',' + node + ')';
}
public Node getNode() {
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/Job.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/Job.java 2010-05-17 23:34:36 UTC (rev 6356)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/Job.java 2010-05-18 03:14:14 UTC (rev 6357)
@@ -3,6 +3,7 @@
import java.io.Serializable;
import java.util.Date;
+import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmContext;
import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.graph.exe.Token;
@@ -12,38 +13,26 @@
private static final long serialVersionUID = 1L;
- long id;
- int version;
+ private long id;
+ private int version;
- Date dueDate;
+ private Date dueDate;
- ProcessInstance processInstance;
- Token token;
- TaskInstance taskInstance;
+ private ProcessInstance processInstance;
+ private Token token;
+ private TaskInstance taskInstance;
- boolean isSuspended;
+ private boolean isSuspended;
+ private boolean isExclusive;
- /**
- * specifies if this job can be executed concurrently with other jobs for the
- * same process instance.
- */
- boolean isExclusive;
+ private String lockOwner;
+ private Date lockTime;
- /**
- * name of the job executor thread that has locked this job.
- */
- String lockOwner;
+ private String exception;
+ private int retries = JbpmConfiguration.Configs.getInt("jbpm.job.retries");
- /**
- * the time the job executor thread locked this job.
- */
- Date lockTime;
+ private String configuration;
- String exception;
- int retries = 1;
-
- String configuration;
-
public Job() {
}
@@ -87,7 +76,10 @@
return id;
}
- public Date getAqcuireDate() {
+ /**
+ * what time the executor locked this job.
+ */
+ public Date getLockTime() {
return lockTime;
}
@@ -95,6 +87,11 @@
this.lockTime = aqcuireDate;
}
+ /** @deprecated call {@link #getLockTime()} instead */
+ public Date getAqcuireDate() {
+ return lockTime;
+ }
+
public Date getDueDate() {
return dueDate;
}
@@ -111,6 +108,10 @@
this.exception = exception;
}
+ /**
+ * whether this job can be executed concurrently with other jobs for the same process
+ * instance.
+ */
public boolean isExclusive() {
return isExclusive;
}
@@ -119,7 +120,10 @@
this.isExclusive = isExclusive;
}
- public String getJobExecutorName() {
+ /**
+ * name of the executor that locked this job.
+ */
+ public String getLockOwner() {
return lockOwner;
}
@@ -127,6 +131,11 @@
this.lockOwner = jobExecutorName;
}
+ /** @deprecated call {@link #getLockOwner()} instead */
+ public String getJobExecutorName() {
+ return lockOwner;
+ }
+
public int getRetries() {
return retries;
}
@@ -151,14 +160,6 @@
this.configuration = configuration;
}
- public String getLockOwner() {
- return lockOwner;
- }
-
- public Date getLockTime() {
- return lockTime;
- }
-
public boolean isSuspended() {
return isSuspended;
}
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/Timer.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/Timer.java 2010-05-17 23:34:36 UTC (rev 6356)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/Timer.java 2010-05-18 03:14:14 UTC (rev 6357)
@@ -15,6 +15,7 @@
import org.jbpm.graph.def.Transition;
import org.jbpm.graph.exe.ExecutionContext;
import org.jbpm.graph.exe.Token;
+import org.jbpm.taskmgmt.exe.TaskInstance;
public class Timer extends Job {
@@ -36,9 +37,11 @@
}
public boolean execute(JbpmContext jbpmContext) throws Exception {
+ Token token = getToken();
ExecutionContext executionContext = new ExecutionContext(token);
executionContext.setTimer(this);
+ TaskInstance taskInstance = getTaskInstance();
if (taskInstance != null) {
executionContext.setTaskInstance(taskInstance);
}
@@ -60,6 +63,7 @@
// then take a transition if one is specified
// and if no unhandled exception occurred during the action
+ String exception = getException();
if (transitionName != null && exception == null) {
Node node = token.getNode();
Transition transition = node.getLeavingTransition(transitionName);
@@ -79,7 +83,7 @@
Duration interval = new Duration(repeat);
long currentTime = System.currentTimeMillis();
- Date repeatDate = dueDate;
+ Date repeatDate = getDueDate();
do {
repeatDate = businessCalendar.add(repeatDate, interval);
} while (repeatDate.getTime() <= currentTime);
@@ -87,13 +91,13 @@
if (log.isDebugEnabled()) {
log.debug("scheduling " + this + " for repeat on " + repeatDate);
}
- dueDate = repeatDate;
+ setDueDate(repeatDate);
// unlock timer so that:
// (a) any job executor thread can acquire it next time
// (b) the engine knows it is not executing and can be deleted
// see https://jira.jboss.org/jira/browse/JBPM-2036
- lockOwner = null;
+ setLockOwner(null);
return false;
}
@@ -108,7 +112,7 @@
text.append(name);
}
else {
- text.append(id);
+ text.append(getId());
}
return text.append(')').toString();
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/executor/JobExecutor.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/executor/JobExecutor.java 2010-05-17 23:34:36 UTC (rev 6356)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/executor/JobExecutor.java 2010-05-18 03:14:14 UTC (rev 6357)
@@ -25,7 +25,6 @@
protected JbpmConfiguration jbpmConfiguration;
protected String name;
protected int nbrOfThreads;
- private int retries;
protected int idleInterval;
protected int maxIdleInterval;
/** @deprecated property has no effect */
@@ -354,13 +353,5 @@
this.nbrOfThreads = nbrOfThreads;
}
- public int getRetries() {
- return retries;
- }
-
- public void setRetries(int retries) {
- this.retries = retries;
- }
-
private static Log log = LogFactory.getLog(JobExecutor.class);
}
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java 2010-05-17 23:34:36 UTC (rev 6356)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java 2010-05-18 03:14:14 UTC (rev 6357)
@@ -131,11 +131,7 @@
job.setLockOwner(lockOwner);
job.setLockTime(lockTime);
// has job failed previously?
- if (job.getException() == null) {
- // initialize retry count to configured value
- job.setRetries(jobExecutor.getRetries());
- }
- else {
+ if (job.getException() != null) {
// decrease retry count
int retries = job.getRetries() - 1;
job.setRetries(retries);
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml 2010-05-17 23:34:36 UTC (rev 6356)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml 2010-05-18 03:14:14 UTC (rev 6357)
@@ -88,9 +88,6 @@
<property name="nbrOfThreads">
<int value="1" />
</property>
- <property name="retries">
- <int value="3" />
- </property>
<property name="idleInterval">
<!-- 5 seconds -->
<int value="5000" />
@@ -108,4 +105,7 @@
<int value="60000" />
</property>
</bean>
+
+ <!-- job retry count -->
+ <int name="jbpm.job.retries" value="3" />
</jbpm-configuration>
Modified: jbpm3/branches/jbpm-3.2-soa/modules/userguide/src/main/docbook/en/modules/configuration.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/userguide/src/main/docbook/en/modules/configuration.xml 2010-05-17 23:34:36 UTC (rev 6356)
+++ jbpm3/branches/jbpm-3.2-soa/modules/userguide/src/main/docbook/en/modules/configuration.xml 2010-05-18 03:14:14 UTC (rev 6357)
@@ -93,19 +93,39 @@
<string name="jbpm.mail.smtp.host" value="localhost" />
<string name="jbpm.mail.from.address" value="jbpm at noreply" />
<bean name="jbpm.mail.address.resolver" class="org.jbpm.identity.mail.IdentityAddressResolver" singleton="true" />
-
- <bean name="jbpm.job.executor" class="org.jbpm.job.executor.JobExecutor">
- <property name="jbpmConfiguration"><ref bean="jbpmConfiguration" /></property>
- <property name="name"><string value="JbpmJobExecutor" /></property>
- <property name="nbrOfThreads"><int value="1" /></property>
- <property name="retries"><int value="3" /></property>
- <property name="idleInterval"><int value="5000" /></property>
- <property name="maxIdleInterval"><int value="3600000" /><!-- 1 hour --></property>
- <property name="maxLockTime"><int value="600000" /><!-- 10 minutes --></property>
- <property name="lockMonitorInterval"><int value="60000" /><!-- 1 minute --></property>
- <property name="lockBufferTime"><int value="5000" /><!-- 5 seconds --></property>
+
+ <!-- job execution properties -->
+ <bean name="jbpm.job.executor" class="org.jbpm.job.executor.JobExecutor" singleton="true">
+ <property name="jbpmConfiguration">
+ <ref bean="jbpmConfiguration" />
+ </property>
+ <property name="name">
+ <string value="JbpmJobExecutor" />
+ </property>
+ <property name="nbrOfThreads">
+ <int value="1" />
+ </property>
+ <property name="idleInterval">
+ <!-- 5 seconds -->
+ <int value="5000" />
+ </property>
+ <property name="maxIdleInterval">
+ <!-- 1 hour -->
+ <int value="3600000" />
+ </property>
+ <property name="maxLockTime">
+ <!-- 10 minutes -->
+ <int value="600000" />
+ </property>
+ <property name="lockMonitorInterval">
+ <!-- 1 minute -->
+ <int value="60000" />
+ </property>
</bean>
+ <!-- job retry count -->
+ <int name="jbpm.job.retries" value="3" />
+
</jbpm-configuration>]]></programlisting>
<para>In this configuration file you can see 3 parts:
@@ -116,10 +136,10 @@
implementations. The possible configuration options are covered in the chapters
that cover the specific service implementations.
</para></listitem>
- <listitem><para>The second part are all mappings of references to configuration
+ <listitem><para>The second part is a series of references to configuration
resources. These resource references can be updated if you want to customize
one of these configuration files. Typically, you make a copy the default configuration
- which is in the <literal>jbpm-3.x.jar</literal> and put it somewhere on the classpath.
+ which is in the <literal>jbpm-jpdl.jar</literal> and put it somewhere on the classpath.
Then you update the reference in this file and jbpm will use your customized version
of that configuration file.
</para></listitem>
@@ -180,12 +200,12 @@
<section id="customizingfactories">
<title>Customizing factories</title>
<para>A common mistake when customizing factories is to mix the short and the long notation.
- Examples of the short notation can be seen in the default configuration file and above: E.g.
+ Examples of the short notation can be seen in the default configuration file and above:
</para>
- <programlisting> ...
- <service name='persistence' factory='org.jbpm.persistence.db.DbPersistenceServiceFactory' /></programlisting>
+ <programlisting> <service name='persistence'
+ factory='org.jbpm.persistence.db.DbPersistenceServiceFactory' /></programlisting>
<para>If specific properties on a service need to be specified, the short notation can't be used, but instead,
- the long notation has to be used like this: E.g.
+ the long notation has to be used like this:
</para>
<programlisting> <service name="persistence">
<factory>
@@ -345,11 +365,6 @@
<entry>1</entry>
</row>
<row>
- <entry>retries</entry>
- <entry>Number of times the job executor retries a failed job</entry>
- <entry>3</entry>
- </row>
- <row>
<entry>idleInterval</entry>
<entry>Period between checks for new jobs (milliseconds)</entry>
<entry>5 seconds</entry>
@@ -375,6 +390,18 @@
</tbody>
</tgroup>
</table>
+
+ <para>In addition to the job executor bean properties, you can indicate the
+ number of times a failed job is retried. Set the <literal>jbpm.job.retries</literal>
+ configuration entry to the desired value. The default is 3.</para>
+ <programlisting><![CDATA[<int name="jbpm.job.retries" value="5" />]]></programlisting>
+ <caution><para>Setting the retry count to a low value may cause <ulink
+ url="https://jira.jboss.org/browse/JBPM-2787">process instances to get stuck</ulink>,
+ whereas a high value causes jobs with unrecoverable exceptions (for instance,
+ database connectivity problems) to be unduly reattempted.</para></caution>
+ <note><para>Alternate implementations of the message and timer service,
+ such as the JCA inflow service included with JBoss ESB, also recognize
+ the <literal>jbpm.job.retries</literal> configuration entry.</para></note>
</section>
<section id="objectfactory">
@@ -396,11 +423,8 @@
<double name="salary">100000000.32</double>
<char name="java">j</char>
<null name="dusttodust" />
-</beans>
-
----------------------------------------------------------
-
-ObjectFactory of = ObjectFactory.parseXmlFromAbove();
+</beans></programlisting>
+ <programlisting>ObjectFactory of = ObjectFactory.parseXmlFromAbove();
assertEquals(TaskInstance.class, of.getNewObject("task").getClass());
assertEquals("hello world", of.getNewObject("greeting"));
assertEquals(new Integer(42), of.getNewObject("answer"));
@@ -410,7 +434,6 @@
assertEquals(new Character('j'), of.getNewObject("java"));
assertNull(of.getNewObject("dusttodust"));</programlisting>
-
<para>Also you can configure lists:</para>
<programlisting><beans>
More information about the jbpm-commits
mailing list