[JBoss jBPM] - Re: saving own objects with Hibernate in jbpm
by jbaton
Hi jits_1998,
As an example, my principal custom object has, amongst its fields, a long that is an id of a jbpm process instance.
This custom object is saved in DB by Hibernate through a regular session while the jbpm process instance is saved using a jbpmcontext.
The hib. session is obtained from the same configuration as jbpm, for having the (few) tables in the same schema is not an issue.
| public static Session createPersistantSession() {
| DbPersistenceServiceFactory dbPersistenceServiceFactory = (DbPersistenceServiceFactory) instanceConfigurationJbpm.getServiceFactory("persistence");
| return dbPersistenceServiceFactory.getSessionFactory().openSession() ;
| }
|
Right now, the issue in the post above is not anymore but I am facing a new one about contexts closed more than once
I'm using version 3.2
| 11:11:03,653 [Thread-3] ERROR DbPersistenceService : problem rolling back after failed commit
| org.hibernate.TransactionException: Transaction not successfully started
| at org.hibernate.transaction.JDBCTransaction.rollback(JDBCTransaction.java:149)
| at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:166)
| at org.jbpm.svc.Services.close(Services.java:211)
| at org.jbpm.JbpmContext.close(JbpmContext.java:139)
| at com.aspheria.cerbere.Workflow.run(Workflow.java:515)
| at java.lang.Thread.run(Thread.java:534)
| 11:11:03,653 [Thread-3] ERROR Services : problem closing service 'persistence'
| org.jbpm.persistence.JbpmPersistenceException: couldn't commit hibernate session
| at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:172)
| at org.jbpm.svc.Services.close(Services.java:211)
| at org.jbpm.JbpmContext.close(JbpmContext.java:139)
| at com.xxxx.cerbere.Workflow.run(Workflow.java:515)
| at java.lang.Thread.run(Thread.java:534)
| Caused by: org.hibernate.TransactionException: Transaction not successfully started
| at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:100)
| at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:162)
| ... 4 more
|
| ... 4 more
| org.jbpm.JbpmException: closed JbpmContext more then once... check your try-finally's around JbpmContexts blocks
| at org.jbpm.JbpmConfiguration.popJbpmContext(JbpmConfiguration.java:521)
| at org.jbpm.JbpmConfiguration.jbpmContextClosed(JbpmConfiguration.java:537)
| at org.jbpm.JbpmContext.close(JbpmContext.java:144)
| at com.xxxx.cerbere.Workflow.run(Workflow.java:515)
| at java.lang.Thread.run(Thread.java:534)
|
Thanks for your help
JBaton
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3970957#3970957
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3970957
19 years, 7 months
[Messaging, JMS & JBossMQ] - Re: MDB multiple queues
by jpersson
Thanks!
Now my MDB is partly annotated and partly XML-descriptor driven. Works fine.
When my MDB runs in two instances is there a concurrency issue when passing incoming messages to the 'next' queue (two mdb instances sending/routing to a single queue) ?
THIS IS SOURCE MDB:
package com.mdm.mdb.bean;
import javax.annotation.Resource;
import javax.ejb.MessageDriven;
import javax.ejb.ActivationConfigProperty;
import javax.jms.Message;
import javax.jms.TextMessage;
import javax.jms.MapMessage;
import javax.jms.ObjectMessage;
import javax.jms.MessageListener;
import javax.jms.JMSException;
import javax.jms.Queue;
import javax.jms.QueueConnection;
import javax.jms.QueueConnectionFactory;
import javax.jms.QueueSender;
import javax.jms.QueueSession;
import javax.jms.Session;
import com.thoughtworks.xstream.XStream;
import static java.lang.System.out;
/** Message Listener setup with annotations, override with XML-descriptor. */
@MessageDriven(activationConfig ={@ActivationConfigProperty(propertyName="destinationType",
propertyValue="javax.jms.Queue")})
public class ServiceBrixRoutingMDB implements MessageListener{
// Dependecy injection.
@Resource(mappedName="java:ConnectionFactory")
QueueConnectionFactory connectionFactory;
// Dependecy injection.
QueueConnection queueConnection;
// Dependecy injection.
@Resource(mappedName="queue/mdm-input")
Queue mDMInputQueue;
// Parser for Object to XML marshaller.
private XStream xstream = null;
/** This is the entry for the message listener. */
public void onMessage(Message messageFromServicemix){
try{
if(messageFromServicemix instanceof TextMessage){
sendMesageToMDM();
}
}catch(Exception e){
out.println(e);
}
}
/** Send MapMessage to MDM node. */
private void sendMesageToMDM() throws JMSException{
QueueSender qsender = null;
queueConnection = getConnection();
QueueSession qsession = queueConnection.createQueueSession(
false, Session.AUTO_ACKNOWLEDGE);
TextMessage mdmMessagge = null;
qsender = qsession.createSender(mDMInputQueue);
mdmMessagge = qsession.createTextMessage("MESSAGE_FROM_SERVICEMIX");
qsender.send(mdmMessagge);
qsession.close();
queueConnection.close();
queueConnection = null;
}
/** Get QueConnection from JBoss Factory. */
private QueueConnection getConnection() throws JMSException{
if (queueConnection == null){
synchronized(connectionFactory){
if(queueConnection == null){
queueConnection = connectionFactory.createQueueConnection();
}
}
}
return queueConnection;
}
/** Get thread safe XStream object for marshall/unmarshall Object/XML. */
private XStream getXStream(){
if(xstream == null){xstream = new XStream();}return xstream;
}
}
THIS IS SOURCE EJBJAR-XML:
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
version="3.0">
Message Driven Bean for Routing from Servicemix to Flowbrix
<display-name>MDB for routing from Servicemix to Flowbrix</display-name>
<enterprise-beans>
<message-driven>
<ejb-name>CPAssistedRequestMDB</ejb-name>
<ejb-class>com.smarttrust.mdm.mdb.bean.ServiceBrixRoutingMDB</ejb-class>
<transaction-type>Bean</transaction-type>
<message-destination-type>javax.jms.Queue</message-destination-type>
<activation-config>
<activation-config-property>
<activation-config-property-name>acknowledgeMode</activation-config-property-name>
<activation-config-property-value>AUTO_ACKNOWLEDGE</activation-config-property-value>
</activation-config-property>
</activation-config>
</message-driven>
<message-driven>
<ejb-name>CPAssistedReplyMDB</ejb-name>
<ejb-class>com.smarttrust.mdm.mdb.bean.ServiceBrixRoutingMDB</ejb-class>
<transaction-type>Bean</transaction-type>
<message-destination-type>javax.jms.Queue</message-destination-type>
<activation-config>
<activation-config-property>
<activation-config-property-name>acknowledgeMode</activation-config-property-name>
<activation-config-property-value>AUTO_ACKNOWLEDGE</activation-config-property-value>
</activation-config-property>
</activation-config>
</message-driven>
</enterprise-beans>
</ejb-jar>
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3970956#3970956
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3970956
19 years, 7 months