Building Stateless and Stateful Business Processes

Business Processes are either Stateless or Stateful, depending on how many transactions are contained in the process.

To learn more about stateless session and entity beans, see Overview: Enterprise Java Beans (EJBs). To learn more about JTA transactions, see Programming WebLogic JTA at the following URL:

http://download.oracle.com/docs/cd/E13222_01/wls/docs81/jta/index.html 

Stateless processes are intended to support business scenarios that involve short-running logic and have high-performance requirements. Because a stateless process does not persist its state to a database, it is optimized for lower-latency, higher-performance execution. An example of a stateless process is one that receives a message asynchronously from a client, transforms the message, and then sends it asynchronously to a resource using a control. Another example is a process that starts with a message broker subscription, transforms a message, and publishes it to another message broker channel. Such a process is analogous to the kinds of routing rules used by traditional message brokering or message routing system.

Stateful processes are intended to support business scenarios that involve complex, long-running logic and therefore have specific reliability and recovery requirements. A process is made stateful by the addition of stateful nodes or logic that forces transaction boundaries (see, Transaction Boundaries). For example, a process that receives a message, transforms it, sends it to a business partner, and then waits for an asynchronous response is stateful because the act of waiting forces a transaction boundary. This is necessary to ensure that:

By default, a business process is Stateless until you add any blocking construct to the data flow, that is, add any process that affects a transaction boundary. For more information about transaction boundaries, see Transaction Boundaries.

To View Whether Your Business Process is Stateless or Stateful

The Start node Property Editor indicates whether a business process is Stateless or Stateful in two different ways:

The following table summarizes the ways in which WebLogic Workshop indicates if your Business Process is Stateless or Stateful.

Stateless
Stateful
Property Editor

stateless = true

stateless = false

Start Node Icon

image

image

You can use the persistence property in the Property Editor to set how a stateful business process is persisted. For more information about the Start node Property Editor, see Setting the Business Process Properties.

Working with Variables in Stateless Processes

Because stateless processes are compiled into stateless session beans and because these stateless session beans are reused at run-time to provide the performance advantage enjoyed by stateless processes, some care is required when working with variables. If a default value is specified for a variable in a stateless process, that variable will only be initialized the first time the process is run. Subsequent process instances will reuse the same stateless session bean instance, and therefore will inherit the last known value of the variable in question.

When building stateless processes that require variables with default values, you should place a Perform node at the start of the process (immediately following the Start node) and manually initialize the variables at that location. This way, you can be assured that the variables will be initialized with each run of the process, because the Perform node will be explicitly executed each time. For more information about how to create Perform nodes, see Writing Custom Java Code in Perform Nodes.

If your goal is merely to have a variable with a constant value, this does not pose an issue in the case of stateless processes. When creating the variable, select the Declare as Constant check box in the Create Variable dialog box. This creates the variable as static and final and ensures that the constant behaves as expected during each run of the stateless process. For more information about how to create variables, see Creating Variables.

Related Topics

Transaction Boundaries

Starting Your Business Process

Writing Custom Java Code in Perform Nodes

Creating Variables

Overview: Enterprise Java Beans (EJBs)

Programming WebLogic JTA at http://download.oracle.com/docs/cd/E13222_01/wls/docs81/jta/index.html

Setting the Business Process Properties

Previous Document Next Document