cancel
Showing results for 
Search instead for 
Did you mean: 

Activiti transaction + JEE transactions

jsher
Champ in-the-making
Champ in-the-making
Hi,

Apologies for these basic questions - I have limited JEE knowledge, but here goes…

I am trying to build a picture of how Activiti will behave in a JEE setting, particularly from a persistence/transactions point of view. I am considering only JEE6 container managed persistence for the moment. I see a couple of different types of interactions and process flows in this regard…

1. Session bean service method invoked in a CMP transaction. Bean invokes Activiti (RS.startProcess(), RS.signal(), TS.complete(), etc). Process executes a JavaDelegate task which in turn invokes methods on EJBs, then reaches a wait state at which changes are persisted.
Q1 - Am I correct in saying that if I use JtaProcessEngineConfiguration, transactionsExternallyManaged=true, and configure data sources appropriately then all persistence operations performed by Activiti will be done in the same transaction as the EJB CMP ?
Q2 - If the answer to the previous is yes, would I be correct in saying that the security context (principal, etc) would be propagated from the initiating session bean, via Activiti, to the EJB invoked by the delegate task ?

2. My process uses a timer or async continuation in which case Activiti executes subsequent tasks in a JobExecutor thread. These tasks may invoke EJBs.
Q3 - How can we avoid violating JEE restriction on managing threads outside of control of the container ?
Q4 - How can execution of these tasks be made to participate in a CMP transaction ? I can't see anything in doc or code to help deal with this. I have read a bit of how jBPM provides for JMS queue for async and I assume this is how jBPM deals with this, and since I understand that Activiti and jBPM share a common heritage I was expecting to see something similar for Activiti.

I'd appreciate some help in answering these questions.

Thanks
    James
14 REPLIES 14

trademak
Star Contributor
Star Contributor
Hi,

Did you look at the Activiti CDI module? Because this provides integration with JEE 6 and EJB's.

Best regards,

meyerd
Champ on-the-rise
Champ on-the-rise
Hi James,

Q1 yes
Q2 yes

Q3 We do not provide support for this. You could write your own JobExecutor and delegate Job acquisition & execution to JEE-container-managed threads there.
Q4 If you configure activiti with JTA, a JTA transaction will be opened for executing the job and if you invoke a SessionBean, the transaction context will be propagated to that bean.

meyerd
Champ on-the-rise
Champ on-the-rise
Maybe as an additional side note:
- we are currentls looking into refactoring the JobExecutor, so that self-management of Threads is factored out and you can plugin your own Thread-management strategy: ACT-34
- I will write a bolg post shortly on activiti integration with websphere application server 8.

jsher
Champ in-the-making
Champ in-the-making
Thanks Tijs. Yes the CDI support is certainly very useful as a starting point.

Regards
   James

jsher
Champ in-the-making
Champ in-the-making
Thanks Daniel for your very helpful replies.

Q3
- re. writing my own JobExecutor… I suspect that JobExecutor is not pluggable currently so I guess this would require custom changes to Activiti which I wouldn't be too keen to do having limited knowledge of the internals. Ideally the experts like yourselves  Smiley Happy would provide such functionality assuming of course there are sufficient requests for this type of feature.

Q4
- I'm still unsure though if there is an issue with a thread not managed by the container (assuming I don't do custom JobExecutor) invoking EJBs. I need to dig into JEE/EJB more to answer this - or maybe someone reading this knows the answer ?

Regards
    James

meyerd
Champ on-the-rise
Champ on-the-rise
Hi James,

Q3
- re. writing my own JobExecutor… I suspect that JobExecutor is not pluggable currently so I guess this would require custom changes to Activiti which I wouldn't be too keen to do having limited knowledge of the internals. Ideally the experts like yourselves Smiley Happy would provide such functionality assuming of course there are sufficient requests for this type of feature.

I will merge branch ACT-34 shortly, that will make it a lot easyer to implement JobExecutor delegating to Threads of your choice (ie. "supported", Container-Managed Threads in an App Server)

pangea
Champ in-the-making
Champ in-the-making
Maybe as an additional side note:
- we are currentls looking into refactoring the JobExecutor, so that self-management of Threads is factored out and you can plugin your own Thread-management strategy: ACT-34
- I will write a bolg post shortly on activiti integration with websphere application server 8.

Wondering if thread management is pluggable in 5.8. We might want to use spring task executor.

meyerd
Champ on-the-rise
Champ on-the-rise
Hi pangea,

not in 5.8

pangea
Champ in-the-making
Champ in-the-making
Hi pangea,

not in 5.8

Could you please let me know the approximate version when this will be included?