Table of Contents
The present chapter describes the facilities offered by jBPM to leverage the Java EE infrastructure.
CommandServiceBean
is a stateless session bean that executes
jBPM commands by calling it's execute method within a separate jBPM context. The environment
entries and resources available for customization are summarized in the table below.
Table 8.1. Command service bean environment
Name | Type | Description |
---|---|---|
JbpmCfgResource | Environment Entry | The classpath resource from which to read the jBPM configuration.
Optional, defaults to jbpm.cfg.xml .
|
ejb/TimerEntityBean | EJB Reference | Link to the local entity bean that implements the scheduler service. Required for processes that contain timers. |
jdbc/JbpmDataSource | Resource Manager Reference | Logical name of the data source that provides JDBC connections to the
jBPM persistence service. Must match the hibernate.connection.datasource
property in the Hibernate configuration file.
|
jms/JbpmConnectionFactory | Resource Manager Reference | Logical name of the factory that provides JMS connections to the jBPM message service. Required for processes that contain asynchronous continuations. |
jms/JobQueue | Message Destination Reference | The jBPM message service sends job messages to the queue referenced here.
To ensure this is the same queue from which the job listener bean receives
messages, the message-destination-link points to a common
logical destination, JobQueue .
|
jms/CommandQueue | Message Destination Reference | The command listener bean receives messages from the queue referenced here.
To ensure this is the same queue to which command messages can be sent,
the message-destination-link element points to a common
logical destination, CommandQueue .
|
CommandListenerBean
is a message-driven bean that listens
on the CommandQueue
for command messages. This bean delegates
command execution to the CommandServiceBean
.
The body of the message must be a Java object that implements the
org.jbpm.Command
interface. The message properties, if any, are ignored.
If the message does not match the expected format, it is forwarded to the
DeadLetterQueue
. No further processing is done on the message.
If the destination reference is absent, the message is rejected.
In case the received message specifies a replyTo
destination,
the result of the command execution is wrapped into an object message and sent
there. The command connection factory environment reference indicates the resource
manager that supplies JMS connections.
Conversely, JobListenerBean
is a message-driven bean that
listens on the JbpmJobQueue
for job messages to support asynchronous
continuations.
The message must have a property called jobId
of type
long
which references a pending Job
in the
database. The message body, if any, is ignored.
This bean extends the CommandListenerBean
and inherits its
environment entries and resource references available for customization.
Table 8.2. Command/Job listener bean environment
Name | Type | Description |
---|---|---|
ejb/LocalCommandServiceBean | EJB Reference | Link to the local session bean that executes commands on a separate jBPM context. |
jms/JbpmConnectionFactory | Resource Manager Reference | Logical name of the factory that provides JMS connections for producing result messages. Required for command messages that indicate a reply destination. |
jms/DeadLetterQueue | Message Destination Reference | Messages which do not contain a command are sent to the queue referenced here. Optional; if absent, such messages are rejected, which may cause the container to redeliver. |
The TimerEntityBean
interacts with the EJB timer service to
schedule jBPM timers. Upon expiration, execution of the timer is actually delegated to
the command service bean.
The timer entity bean requires access to the jBPM data source for reading timer
data. The EJB deployment descriptor does not provide a way to define how an entity bean
maps to a database. This is left off to the container provider. In JBoss AS, the
jbosscmp-jdbc.xml
descriptor defines the data source JNDI name and
the relational mapping data (table and column names, among others). Note that the
JBoss CMP descriptor uses a global JNDI name (java:JbpmDS
),
as opposed to a resource manager reference (java:comp/env/jdbc/JbpmDataSource
).
Earlier versions of jBPM used a stateless session bean called TimerServiceBean
to interact with the EJB timer service. The session approach had to be abandoned
because there is an unavoidable bottleneck at the cancelation methods. Because session beans
have no identity, the timer service is forced to iterate through all
the timers for finding the ones it has to cancel. The bean is still around for backwards
compatibility. It works under the same environment as the TimerEntityBean
,
so migration is easy.
Table 8.3. Timer entity/service bean environment
Name | Type | Description |
---|---|---|
ejb/LocalCommandServiceBean | EJB Reference | Link to the local session bean that executes timers on a separate jBPM context. |