Friday, May 10, 2019

TIBCO BW 5.x Best Practices - Part 3 - Synchronization


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

BW provides the option of synchronizing shared activities for concurrent process instances through critical section groups. A critical section group ensures that while a process instance executes the critical section grouped activities, all other concurrently running processing instances attempting to execute the same group of activities will be blocked until the previous process instance completes.

BW provides the option to synchronize
  • All process instances for a single process definition
  • Process instances of multiple process definitions
  • Process instances across multiple process engines

For option 3 above, process engines must use database for storage. Synchronization is achieved by creating a database transaction to ensure that only one process instance across multiple engines is executing the critical section group at a time.

Judicious usage of critical section groups is recommended since they impact performance by forcing concurrent processes to execute sequentially for critical section activities. When the process logic requires usage of critical section groups, developers should adhere to the following guidelines
  • Use least number of activities possible in the critical section group to keep the execution processing time short and to avoid blocking other processes for longer period.
  • Do not use request-reply activities or activities that block while waiting for a response or timed activities like Wait-For and Sleep activities
  • Avoid nesting critical section groups. If nesting is required, use the lock shared configuration resource in the same order in all process definitions to avoid deadlocks
  • When using Critical Section groups to retrieve or assign a value to a shared variable across multiple process engines, ensure that the Lock and the Shared Variable shared configuration resources have the Multi-Engine field checked and it is set to the same value for both resources. Database storage is a must in this case.

In Summary
When using critical section groups, use few activities inside the group and Global variable for multi-engine setting. Avoid nesting critical section groups and activities that require waiting.

No comments:

Post a Comment

=