This content has been marked as final.
Show 4 replies
-
1. Re: jBPM Persistent Transaction Management
marcus.junk Aug 15, 2005 10:25 PM (in response to marcus.junk)Solution / Advice :
JBPM is able to support the scenario I described above, or more to the point I think it is actually hibernate that supports this transaction management, which could explain why I recieved no responses to this problem.
In short to solve the problem I did the following.
Modified the hibernate.properties to talk to a data source and to use JTA Transaction management.
hibernate.jndi.class=org.jboss.naming.NamingContextFactory
hibernate.connection.datasource=java:comp/env/jdbc/XXXDB
hibernate.transaction.factory_class = net.sf.hibernate.transaction.JTATransactionFactory
Then using JTA transaction management I simply set up my EJB to provide a transaction for my calling method and this provided the required transaction functionality across both my ejb data source and the JBPM data source.
hope this helps those with the same problem or question about JBPM's transaction ability within JBoss.
M. -
2. Re: jBPM Persistent Transaction Management
marcus.junk Aug 15, 2005 11:45 PM (in response to marcus.junk)My previous post was not complete.
we also needed to add the following properties to the hibernate.properties file.
hibernate.transaction.flush_before_completion=true
hibernate.connection.release_mode=after_statement
hibernate.transaction.auto_close_session=true
And finally the most crucial point was that at the end of the EJB method that owns the transaction we needed to explicitly call flush on the underlying hibernate session as the code snippet below illustrates. If I didn't explicity call the flush on the hibernate session then I got my business process saved in a mid process state, even thou the business process should have completed immediately as I knew actually happened thru remote debug sessions./** * @throws Exception * * @ejb.interface-method * @ejb.transaction * type="Required" */ public void testBusinessProcess() throws Exception { // need to hook into current singleton jbpmSessionFactory using JNDI JbpmSessionFactory jbpmSessionFactory = (JbpmSessionFactory) new JndiContext().lookup("java:/jbpm/JbpmSessionFactory", JbpmSessionFactory.class); JbpmSession jbpmSession = jbpmSessionFactory.openJbpmSession(); try { ProcessDefinition processDefinition = jbpmSession.getGraphSession().findLatestProcessDefinition(bpName); jbpmSession.getGraphSession().findProcessInstances(processDefinition.getId()); ProcessInstance processInstance = new ProcessInstance(processDefinition); processInstance.signal(); jbpmSession.getGraphSession().saveProcessInstance(processInstance); jbpmSession.getSession().flush(); } finally { jbpmSession.close(); } }
excuse the nasty code formatting above but thats as best I could do after copy and pasting into this forum editor.
M. -
3. Re: jBPM Persistent Transaction Management
russelldb Aug 17, 2005 10:21 AM (in response to marcus.junk)Many thanks for posting your solution. You have helped me enormously.
Regards
Russell -
4. Re: jBPM Persistent Transaction Management
llucifer Oct 4, 2005 1:15 PM (in response to marcus.junk)Markus, how do you deploy jbpm? Do you include the libraries in your ear or do you deploy jpbm as a .sar?