Friday, May 10, 2019

TIBCO BW 5.x Best Practices - Part 2 - Event Sequencing

This is Part 2 of the series on Best practices for TIBCO BusinessWorks (BW) 5.x platform. You can check out Part 1 here. To check your BW 5.x projects or EAR files for adherence to Best practices and ensure optimal performance, you can do a code review in our free online version at BW5 Code Scanner

Event Sequencing

TIBCO BW engine is designed to execute multiple process instances concurrently. The processing speed of each event depends on the complexity of business logic and the processing path of the generated event. In some cases, jobs waiting on external resources are paged to disk while another job with different but related event is processed earlier due to different processing logic. This could often result in loss of arrival order for received events.

The loss of order when processing received events could violate the business rules which may require a guarantee of event order and sequential processing of events. For example, an order update needs to be processed after the order creation.

To address this sequencing issue, BW offers two mechanisms.

  • Runtime configuration with Max Jobs = 1 and activation limit being set. Max jobs setting specifies the maximum number of process instances that can concurrently be loaded into memory. Activation limit specifies that once a process is loaded, it must remain in memory until it is completed. When Max Jobs is set equal to 1 and the activation limit is set, BW engine loads only one job in memory and completes it before loading another job. Any process instances created during the processing of first job are paged out to disk. This setting causes the process engine to incur some overhead for managing the paging of process instances to and from disk.
  • Design time configuration with sequencing key set on the process starter activity. For this configuration, process instances that have the sequencing key evaluated to the same value are executed in the order they were received. 
Usage of sequencing key is recommended where possible since it has less paging overhead and is more flexible and efficient. For example, if there are 10 messages on a queue that represent creation or updates of 3 different orders, runtime configuration of maxJobs =1 processes one message after another while setting the sequencing key ensures the processing of 3 orders concurrently thereby increasing the processing performance significantly by 300% (other things being equal).

Note: The above approaches are applicable to simple sequencing requirements of projects. Also, the approaches above do not satisfy the sequencing requirements when the application is deployed in a load-balanced mode. For complex sequencing scenarios, applications are recommended to use the sequencer pattern.

In Summary

For simple sequencing requirements, use job sequencing key to preserve order of related events. If un-related events require sequential processing use MaxJobs =1 and activation limit.

No comments:

Post a Comment