[
https://jira.jboss.org/jira/browse/JBPM-1454?page=com.atlassian.jira.plug...
]
Pavel Kadlec updated JBPM-1454:
-------------------------------
Affects Version/s: jPDL 3.2.3
Description:
The method JobSession.getFirstAcquirableJob always acquires first available job. When
using multithreaded JobExecutor, there is bigger probability that the JobExecutor threads
takes the same job that will cause StaleObjectState exception.
I propose to add some random to the method JobSession.getFirstAcquirable.
Proposal solution
public Job getFirstAcquirableJob(String lockOwner) {
Job job = null;
try {
Query query = session.getNamedQuery("JobSession.getFirstAcquirableJob");
query.setString("lockOwner", lockOwner);
query.setTimestamp("now", new Date());
query.setMaxResults(10); // TODO Magic number
List results = query.list();
int numResults = results.size();
if (numResults > 0) {
int whichResult = (int)(Thread.currentThread().getId() % numResults);
job = (Job)results.get(whichResult);
}
} catch (Exception e) {
log.error(e);
throw new JbpmException("couldn't get acquirable jobs", e);
}
return job;
}
Add some random when JobExecutorThread acquiring job
-----------------------------------------------------
Key: JBPM-1454
URL:
https://jira.jboss.org/jira/browse/JBPM-1454
Project: JBoss jBPM
Issue Type: Feature Request
Security Level: Public(Everyone can see)
Affects Versions: jPDL 3.2.3
Reporter: Pavel Kadlec
The method JobSession.getFirstAcquirableJob always acquires first available job. When
using multithreaded JobExecutor, there is bigger probability that the JobExecutor threads
takes the same job that will cause StaleObjectState exception.
I propose to add some random to the method JobSession.getFirstAcquirable.
Proposal solution
public Job getFirstAcquirableJob(String lockOwner) {
Job job = null;
try {
Query query = session.getNamedQuery("JobSession.getFirstAcquirableJob");
query.setString("lockOwner", lockOwner);
query.setTimestamp("now", new Date());
query.setMaxResults(10); // TODO Magic number
List results = query.list();
int numResults = results.size();
if (numResults > 0) {
int whichResult = (int)(Thread.currentThread().getId() % numResults);
job = (Job)results.get(whichResult);
}
} catch (Exception e) {
log.error(e);
throw new JbpmException("couldn't get acquirable jobs", e);
}
return job;
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira