[jboss-user] [JBoss jBPM] - Re: Solution: JBPM3 and Spring Integration
mr_magoo
do-not-reply at jboss.com
Wed Aug 19 18:56:28 EDT 2009
The problem to point out is the job executor thread. The overrided example given does not synchronise the acquire jobs properly. This means that there will be a race condition in the acquire jobs thread between the acquireJobs synchronized block in JobExecutorThread and the unsynched one in SpringExecutorThread.
The correct implementation is:
public class SpringExecutorThread extends JobExecutorThread {
|
| private TransactionTemplate transactionTemplate;
| private JobExecutor jobExecutor;
|
| public GfgSpringExecutorThread(
| String name,
| JobExecutor jobExecutor,
| JbpmConfiguration jbpmConfiguration,
| TransactionTemplate transactionTemplate,
| int idleInterval,
| int maxIdleInterval,
| long maxLockTime,
| int maxHistory
| ) {
| super(name, jobExecutor, jbpmConfiguration, idleInterval, maxIdleInterval, maxLockTime, maxHistory);
| this.transactionTemplate = transactionTemplate;
| this.jobExecutor=jobExecutor;
| }
| @Override
| protected Collection acquireJobs() {
| synchronized(jobExecutor) {
| return (Collection) transactionTemplate.execute(new TransactionCallback() {
| public Object doInTransaction(TransactionStatus transactionStatus) {
| return GfgSpringExecutorThread.super.acquireJobs();
| }
| });
| }
| }
| @Override
| protected void executeJob(final Job job) {
| transactionTemplate.execute(new TransactionCallback() {
| public Object doInTransaction(TransactionStatus transactionStatus) {
| GfgSpringExecutorThread.super.executeJob(job);
| return null;
| }
| });
| }
| @Override
| protected Date getNextDueDate() {
| return (Date) transactionTemplate.execute(new TransactionCallback() {
| public Object doInTransaction(TransactionStatus transactionStatus) {
| return GfgSpringExecutorThread.super.getNextDueDate();
| }
| });
| }
| }
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4250509#4250509
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4250509
More information about the jboss-user
mailing list