IBM BPM, V8.0.1, All platforms > Authoring services in Integration Designer > Developing business processes > Building business state machines > Business state machines

An example of a business state machine

Business state machines can be used in a transaction like those performed by a vending machine. Such an example is provided as an illustration.


Example

Let us begin with an example of a business state machine and see how it would be used to control the purchase of a can of soda pop from a vending machine.

Figure 1. A simple business state machine

In this example, a user goes through the appropriate steps to purchase a can from a vending machine. The vending machine did not respond until money was deposited, and even then, did not proceed to the next state until the amount of money was sufficient. In each of the states in this example, the actions that the customer could perform were unique from any other state.

For example, when it was in the primary state waiting for money, the customer could press buttons, but it would have no effect on the transaction.


Correlations

Real life business transactions, such as the one shown previously, can be modelled using a business state machine. The previous example was fairly simple, but in a typical business, the same type of business transaction will be repeated with multiple customers, often at the same time. With so much going on, it is easy to lose track of the status of these interactions, so the business state machine uses correlation sets to distinguish the parties in their initial interaction so that they can recognize each other in the future. A correlation set is the record used to keep track of multiple participants in the same business transaction.

Consider the following example:

Figure 2. A business transaction that uses correlations to identify customers

In this example, a customer goes to the vendor's store looking for a specific item that is ultimately sold out. Accordingly, the vendor issues a rain-check to the customer so that when there is sufficient stock, the customer can return and the vendor will be able to pick up the business transaction where it left off. The vendor is essentially assigning a token to the customer used to identify the customer when the transaction resumes.

It is important to note that the vendor is able to manage multiple tasks, and does not suspend business waiting for this one transaction to conclude. Instead, while they are waiting for the object to arrive, the vendor conducts similar business, using the same business process, with other customers.


Timeouts

A timeout is an expiration that is imposed upon a state. It is used to ensure that a state will not be maintained indefinitely while waiting for an operation that may never occur.

Consider this slight variation of the previous example:

Figure 3. An example of a timeout used with a business state machine

In this version of the example, the completion of the business state machine is interrupted by a lack of funds. The customer leaves to get more money, leaving the vending machine waiting in a single state. In this machine, a timeout duration has been set on this state, and after waiting in vain for a specified period of time, the existing money is returned, the current state is canceled, and the machine returns to the initial state.

Business state machines