Copyright © Cloud Software Group, Inc. All Rights Reserved
Copyright © Cloud Software Group, Inc. All Rights Reserved


Chapter 12 Process Instance Execution : Sequencing Process Instances

Sequencing Process Instances
Process instances can be executed in the order they were created. TIBCO ActiveMatrix BusinessWorks allows you to specify a sequencing key on process starters that determines which process instances to execute sequentially. Process instances with sequencing keys that evaluate to the same value are executed in the order they were started. Process instances can have sequencing keys that evaluate to different values, but only process instances with the same value for the sequencing key are executed sequentially. Process instances with different sequencing key values can be executed concurrently.
TIBCO ActiveMatrix BusinessWorks also allows you to control process execution administratively by setting properties in the deployment configuration of the project. TIBCO Administrator allows you to control the maximum number of process instances in memory as well as the maximum number of concurrently executing process instances. Using these settings, you can specify that all process instances should be executed sequentially in the order they were created. This method is not as flexible as using the Sequencing Key field on a process starter. Using the administrator settings is only recommended when you cannot change the process definitions in the project before deployment (for example, if you purchase a pre-built project from a third party).
This chapter details examples of using the Sequencing Key field on the Misc tab of process starters to control the order of process execution. For more information on using TIBCO Administrator to set deployment configuration parameters, see TIBCO ActiveMatrix BusinessWorks Administration.
Example 1: Processing Orders As They Are Received
In this example, an order-entry system must process incoming orders in the order in which they are received. The orders are placed using a web client and the TIBCO ActiveMatrix BusinessWorks process definition uses an HTTP Receiver process starter to accept the incoming orders. Figure 38 illustrates the example process definition.
Figure 38 Example order-entry system
In this example, you wish to sequentially execute all orders that are accepted by this process definition. To accomplish this, specify a constant in the Sequencing Key field of the Misc tab of the AcceptOrder HTTP Receiver process starter. For example, place "OrderEntry" in the Sequencing Key field. Because you placed a constant in the field, the value of the XPath expression is identical for each incoming order. Therefore, all new orders are executed in the order they are received.
Example 2: Periodic Processing
In this example, the Timer process starter is used to start a process every five minutes. The process is a monitoring application that examines data in a database and performs the appropriate action. For example, if the number of rows returned by a query is greater than 5000, the process archives the data to another database and removes all rows from the table. If the number of rows is less than 5000, the results of the query are processed and stored in a separate table. Figure 39 illustrates the example process definition.
Figure 39 Example of periodic processing
In this example, process instances are created every five minutes, but the data in the table changes much more frequently. You must ensure that the data returned by the query is processed before the next query executes. Therefore, you must execute each process instance sequentially before executing the next process instance. System backups occur at midnight each night, and there are no changes to the table during this time.
To configure sequential processing in this scenario, you can use the XPath expression pfx:TimerOutputSchema/Day_Of_Month in the Sequencing Key field of the Misc tab of the Timer process starter. This ensures that process instances created each day are completed sequentially in the order they are created. At the end of the day, no updates are occurring to the table, so process instances created at the end of each day can execute concurrently with the first process instance created the next day.
Example 3: Handling Client Messages
In this example, a JMS application sends messages to TIBCO ActiveMatrix BusinessWorks for processing. Each JMS client authenticates to the JMS server with a different user ID. Messages from different clients are permitted to be processed concurrently, but all messages received from the same client must be processed in the order they are received.
Figure 40 Example of handling incoming messages
In this example, you can use the expression pfx:ActivityOutput/JMSProperties/pfx:JMSXUserID in the Sequencing Key field of the Misc tab of the JMS Topic Subscriber process starter. This ensures that all messages from a specific client are processed in the order they are received.

Copyright © Cloud Software Group, Inc. All Rights Reserved
Copyright © Cloud Software Group, Inc. All Rights Reserved