Bug 780166 (SOA-2542)

Summary: Change the Exclusive Processing behaviour for Jobs processing with JMS inflow
Product: [JBoss] JBoss Enterprise SOA Platform 5 Reporter: Brad Davis <brad.davis>
Component: JBPM - within SOAAssignee: Marco Rietveld <mrietvel>
Status: CLOSED WONTFIX QA Contact:
Severity: high Docs Contact:
Priority: high    
Version: 5.0.2CC: atangrin, ldimaggi, mbaluch, smcgowan
Target Milestone: ---   
Target Release: FUTURE   
Hardware: Unspecified   
OS: Unspecified   
URL: http://jira.jboss.org/jira/browse/SOA-2542
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-12-06 16:37:28 UTC Type: Feature Request
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Attachments:
Description Flags
sample-jbpm-1.0.0.par
none
server.log none

Description Brad Davis 2010-11-03 19:48:59 UTC
project_key: SOA

jBPM's Job Executor has a property for exclusive jobs.  This can be implemented in SOA-P's JMS based executor using the mechanism described in the support case:

https://access.redhat.com/support/cases/00371420

This is needed because often multiple threads working on the same workflow can lead to StaleObjectExceptions.  The approach would use JMS GroupIDs to group messages to one consumer, if the async="exclusive" tag is used in the Workflow.  The group ID would be the Process ID in the case of the jBPM node.

Comment 1 Kevin Conner 2010-11-03 20:23:52 UTC
At present we copy the enterprise behaviour in jBPM, for example the following

    if (job.isExclusive()) {
        jbpmContext.getGraphSession().lockProcessInstance(processInstance);
    }

I'm assuming from your report that this does not work properly so can you please provide a working test case and logs?

The linked support case is not visible to me.

Comment 2 Brad Davis 2010-11-03 20:36:52 UTC
Lock Upgrade puts a database lock, which makes other threads wait for the lock to be removed before continuing until a timeout or the lock is removed.

Also, once it does unlock, every live thread dealing with the same process ID gets a StaleObjectException.  So they restart, each locking the db and gumming things up. 

If you make this simple change, then you shouldn't encounter these problems.

Comment 3 Brad Davis 2010-11-03 20:40:11 UTC
I can create a process which demonstrates this.  

Comment 4 Brad Davis 2010-11-03 20:40:34 UTC
I will work on that and attach it.

Comment 5 Kevin Conner 2010-11-03 20:40:40 UTC
Sounds like it should be straight forward for you to provide me with an example in that case.  I will decide on the 'simple' change once I have seen what is happening.

Comment 6 Kevin Conner 2010-11-03 20:42:09 UTC
I should also add that the exclusivity only applies to Jobs in the jBPM codebase, not timers nor commands.


Comment 7 Brad Davis 2010-11-03 22:21:01 UTC
Kevin, attached is the example.  To run it, deploy the process and then through the jbpm console start and signal the initial token.


Comment 8 Brad Davis 2010-11-03 22:21:24 UTC
Process with failure of timers, AKA Jobs.

Comment 9 Brad Davis 2010-11-03 22:21:24 UTC
Attachment: Added: sample-jbpm-1.0.0.par


Comment 10 Brad Davis 2010-11-03 22:25:22 UTC
Also, I have tried this with the HSQL and Postgres databases behind jBPM.  


Comment 11 Brad Davis 2010-11-03 22:55:51 UTC
Attached is the log requested.  As you can see, with jBPM and Postgres, timers and async="exclusive" for the Join, you still get issues with the StaleObjectExceptions.

Comment 12 Brad Davis 2010-11-03 22:55:51 UTC
Attachment: Added: server.log


Comment 13 Kevin Conner 2010-11-04 07:14:01 UTC
Fantastic, thanks very much for that.

Please note that timer execution is *not* the same as job execution in the current codebase, only jobs are protected by exclusivity as I mentioned earlier. Timers are *not* AKA jobs.

If my gut instinct is correct then there may be a couple of areas that need tidying up.

Comment 14 Brad Davis 2010-11-04 13:19:38 UTC
The approach I used at a client which worked very well was to add:

message.setStringProperty("JMSXGroupID","jBPMPID:"+job.getProcessInstance().getId());

to the Messaging Service, when the Job was to execute exclusively.  This allows the JMS system to only deliver to one consumer.  The benefit of this is that it does not lock the DB, which can really gum up systems if you have a large number of exclusive jobs. 

Comment 15 Brad Davis 2010-11-04 13:21:47 UTC
About Timers vs Jobs, either way is fine with me.  I thought I saw in your codebase that the JobListener picks up Timers and then creates a Command object.  I guess I assumed you had Timers going to the Job queue.

EItherway, the approach I am using should not be used with Timers.  Only Jobs.  The reason is that JBoss Messaging recommends you *not* set both the scheduled delivery property and the group ID.  

Comment 16 Kevin Conner 2010-11-04 15:50:26 UTC
It does create commands, but a different one for each.  It is the command that does the locking.

The approach you have chosen does affect both timers and jobs but is not recommended, as you have found.  I also suspect another area needs changing, but will chase this up when I look at it in detail.

Comment 17 Brad Davis 2010-11-04 16:34:08 UTC
Kevin, the approach I took does not affect timers.  I only add that property when it is not a timer.  The source for that is:

if(!(job instanceof Timer) && job.isExclusive())
{
    		message.setStringProperty(JMS_PROP_GROUP, JBPM_GROUP_PREFIX+job.getProcessInstance().getId());
}

Comment 18 Anne-Louise Tangring 2010-11-09 15:40:11 UTC
Not a candidate for SOA 5.1.0

Comment 19 (please assign to mrietvel@redhat.com) 2011-11-02 12:21:12 UTC
Link: Added: This issue Cloned to JBPM-3424


Comment 21 Marco Rietveld 2012-12-06 16:37:28 UTC
Given the following: 

1. https://access.redhat.com/support/cases/00371420 mentions that "this is more of a feature request than an outright bug or breakdown"
2. jBPM 3 is in maintenance mode for SOA 5, and slowly but surely nearing EOL. 
3. We should _not_ be encouraging any dependence on jBPM 3 and should be encouraging migration to jBPM 5. 

Given above, I'm closing this bug. The only issues that should be fixed at this point for jbpm 3 are bugs that break things for clients. 

If I'm incorrect on this, please reopen the issue.