[jbpm-commits] JBoss JBPM SVN: r1595 - jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/job/executor.
do-not-reply at jboss.org
do-not-reply at jboss.org
Fri Jul 11 13:24:48 EDT 2008
Author: alex.guizar at jboss.com
Date: 2008-07-11 13:24:48 -0400 (Fri, 11 Jul 2008)
New Revision: 1595
Modified:
jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java
Log:
refined jbpm persistence exception handling in job executor
Modified: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java
===================================================================
--- jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java 2008-07-11 16:11:52 UTC (rev 1594)
+++ jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java 2008-07-11 17:24:48 UTC (rev 1595)
@@ -10,14 +10,11 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.hibernate.Hibernate;
import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmContext;
import org.jbpm.db.JobSession;
import org.jbpm.job.Job;
-import org.jbpm.job.Timer;
import org.jbpm.persistence.JbpmPersistenceException;
-import org.jbpm.persistence.db.StaleObjectLogConfigurer;
import org.jbpm.svc.Services;
public class JobExecutorThread extends Thread {
@@ -104,12 +101,13 @@
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
try {
JobSession jobSession = jbpmContext.getJobSession();
+ String lockOwner = getName();
log.debug("querying for acquirable job...");
- Job job = jobSession.getFirstAcquirableJob(getName());
+ Job job = jobSession.getFirstAcquirableJob(lockOwner);
if (job!=null) {
if (job.isExclusive()) {
log.debug("exclusive acquirable job found ("+job+"). querying for other exclusive jobs to lock them all in one tx...");
- List otherExclusiveJobs = jobSession.findExclusiveJobs(getName(), job.getProcessInstance());
+ List otherExclusiveJobs = jobSession.findExclusiveJobs(lockOwner, job.getProcessInstance());
jobsToLock = otherExclusiveJobs;
log.debug("trying to obtain a process-instance exclusive locks for '"+otherExclusiveJobs+"'");
} else {
@@ -117,18 +115,19 @@
jobsToLock = Collections.singletonList(job);
}
- Iterator iter = jobsToLock.iterator();
- while (iter.hasNext()) {
+ Date lockTime = new Date();
+ for (Iterator iter = jobsToLock.iterator(); iter.hasNext();) {
job = (Job) iter.next();
- job.setLockOwner(getName());
- job.setLockTime(new Date());
+ job.setLockOwner(lockOwner);
+ job.setLockTime(lockTime);
// jbpmContext.getSession().update(job);
}
// HACKY HACK : this is a workaround for a hibernate problem that is fixed in hibernate 3.2.1
- if (job instanceof Timer) {
- Hibernate.initialize(((Timer)job).getGraphElement());
- }
+ // TODO is this still needed?
+ // if (job instanceof Timer) {
+ // Hibernate.initialize(((Timer)job).getGraphElement());
+ // }
} else {
log.debug("no acquirable jobs in job table");
}
@@ -141,7 +140,7 @@
catch (JbpmPersistenceException e) {
// if this is a stale object exception, keep it quiet
if (Services.isCausedByStaleState(e)) {
- log.debug("optimistic locking failed, couldn't obtain lock on jobs: "+jobsToLock);
+ log.debug("optimistic locking failed, couldn't obtain lock on jobs "+jobsToLock);
acquiredJobs = Collections.EMPTY_LIST;
} else {
throw e;
@@ -180,13 +179,10 @@
try {
jbpmContext.close();
} catch (JbpmPersistenceException e) {
- // if this is a stale object exception, the jbpm configuration has control over the logging
- if ("org.hibernate.StaleObjectStateException".equals(e.getCause().getClass().getName())) {
- log.info("problem committing job execution transaction: optimistic locking failed");
- StaleObjectLogConfigurer.staleObjectExceptionsLog.error("problem committing job execution transaction: optimistic locking failed", e);
+ // if this is a stale object exception, keep it quiet
+ if (Services.isCausedByStaleState(e)) {
+ log.debug("optimistic locking failed, couldn't complete job "+job);
} else {
- // TODO run() will log this exception, log it here too?
- log.error("problem committing job execution transaction", e);
throw e;
}
}
More information about the jbpm-commits
mailing list