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 JNDI name of the JMS connection
factory. Defaults to java:comp/env/jms/JbpmConnectionFactory
.
destinationJndiName
: the JNDI name of the JMS destination where
job messages are sent. Must match the destination where JobListenerBean
receives messages. Defaults to java:comp/env/jms/JobQueue
.
isCommitEnabled
: tells whether the message service should
create a transacted session and either commit or rollback on close. Messages produced by the
JMS message service are never meant to be received before the database transaction commits.
The J2EE
tutorial states "when you create a session in an enterprise bean, the container
ignores the arguments you specify, because it manages all transactional properties for
enterprise beans". Unfortunately the tutorial fails to indicate that said behavior is not
prescriptive. JBoss ignores the transacted
argument if the
connection factory supports XA, since the overall JTA transaction controls the session.
Otherwise, transacted
produces a locally transacted session. In Weblogic, JMS transacted
sessions are agnostic to JTA transactions even if the connection factory is XA enabled.
With isCommitEnabled
set to false
(the default),
the message service creates a nontransacted, auto-acknowledging session. Such a session
works with containers that either disregard the creation arguments or do not bind
transacted sessions to JTA. Conversely, setting isCommitEnabled
to
true
causes the message service to create a transacted session and commit
or rollback according to the TxService.isRollbackOnly
method.
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
.