jbpm.cfg.xml
includes the following configuration items:
<jbpm-context> <service name="persistence" factory="org.jbpm.persistence.jta.JtaDbPersistenceServiceFactory" /> <service name="message" factory="org.jbpm.msg.jms.JmsMessageServiceFactory" /> <service name="scheduler" factory="org.jbpm.scheduler.ejbtimer.EntitySchedulerServiceFactory" /> </jbpm-context>
JtaDbPersistenceServiceFactory
enables jBPM to participate in JTA
transactions. If an existing transaction is underway, the JTA persistence service clings to it;
otherwise it starts a new transaction. The jBPM enterprise beans are configured to delegate
transaction management to the container. However, if you create a JbpmContext in an environment
where no transaction is active (say, in a web application), one will be started automatically.
The JTA persistence service factory has the configurable fields described below.
isCurrentSessionEnabled
: if true
, jBPM will
use the "current" Hibernate session associated with the ongoing JTA transaction. This is the
default setting. See the Hibernate guide, section
2.5 Contextual sessions for a description of the behavior. You can take advantage
of the contextual session mechanism to use the same session used by jBPM in other parts
of your application through a call to SessionFactory.getCurrentSession()
.
On the other hand, you might want to supply your own Hibernate session to jBPM. To do so,
set isCurrentSessionEnabled
to false
and inject the
session via the JbpmContext.setSession(session)
method. This will also
ensure that jBPM uses the same Hibernate session as other parts of your application. Note,
the Hibernate session can be injected into a stateless session bean via a persistence context,
for example.
isTransactionEnabled
: a true
value for this
field means jBPM will begin a transaction through Hibernate's transaction API (section
11.2. Database transaction demarcation of the Hibernate manual shows the API) upon
JbpmConfiguration.createJbpmContext()
, commit the transaction and close the
Hibernate session upon JbpmContext.close()
. This is NOT the desired
behaviour when jBPM is deployed as an ear, hence isTransactionEnabled
is set
to false
by default.
JmsMessageServiceFactory
leverages the reliable communication
infrastructure exposed through JMS interfaces to deliver asynchronous continuation messages
to the JobListenerBean
. The JMS message service factory exposes the following
configurable fields.
connectionFactoryJndiName
: the name of the JMS connection factory
in the JNDI initial context. Defaults to java:comp/env/jms/JbpmConnectionFactory
.
destinationJndiName
: the name of the JMS destination where job
messages will be sent. Must match the destination from which JobListenerBean
receives messages. Defaults to java:comp/env/jms/JobQueue
.
isCommitEnabled
: tells whether jBPM should commit the JMS session
upon JbpmContext.close()
. Messages produced by the JMS message service are
never meant to be received before the current transaction commits; hence the JMS sessions
created by the service are always transacted. The default value -false
- is
appropriate when the connection factory in use is XA capable, as the JMS session's produced
messages will be controlled by the overall JTA transaction. This field should be set to
true
if the JMS connection factory is not XA capable so that jBPM commits
the JMS session's local transaction explicitly.
EntitySchedulerServiceFactory
builds on the transactional notification
service for timed events provided by the EJB container to schedule business process timers. The
EJB scheduler service factory has the configurable field described below.
timerEntityHomeJndiName
: the name of the
TimerEntityBean
's local home interface in the JNDI initial context.
Defaults to java:comp/env/ejb/TimerEntityBean
.