Time to share more implementation tips and tricks. This time, we will share ideas on how th manage and synchronize jobs instantiated by a parent job.
You can launch child workfows from any running workflow in appRules in the following ways:
- Custom Function
You can use the App.ExecuteWorkflow() method in a custom function to launch a child workflow.
- ExecuteWorkflow Activity
You can add and configure an ExecuteWork activity anywhere in your workflow to launch a child workflow
- SplitFile Activity
When a SplitFile workflow activity is used to split a file, it can also launch a child workflow to process the records in the files.
- WatchFileSystem Activity
When a WatchFileSystem workflow activity is used to implement a file watcher (file drop) solution, it can also launch a child workflow to process the records in the files.
- Target DataManager
You can configure the HighPerformance property of some Target activities to process records in batches. A child workflow can be launched to process records in each batch.
If the child workflows are launched as separate processes (asynchronous), there is the possibility that they will still be running when the parent workflow is completed. Depending on the project, it may not be a big deal to have child workflows running while the parent is no longer running. But for other projects, there is a need to synchronize the running of the child workflows with the parent workflow. Depending on the project, you may want to relate the child workflows to the parent, while in other projects, it is not as important to relate child and parent workflows. Tying child workflows to their parent allows you to easily navigate to them while viewing Project Run Details.
Relating Parent and Child Workflows
When a child workflow is launched, unless it is tied to the parent workflow, it is free to start and run without any link to the parent. In that case, no parent relationship information is captured and stored for the child workflow. To related a child workflow to a parent, the parent workflow information must be passed as arguments to the child workflow. The arguments must be defined as follows in the child workflow:
When a child workflow is launched from a SplitFile activity or from a Target activity, the arguments are automatically passed to the child workflow. If the ProjectId and ProjectInstanceId of the parent workflow are not included in the argument list, the child workflow will not be launched successfully.
When a child workflow is launched from a custom function or from an ExecuteWorkflow activity, the arguments must be specified in the parameters list as follows:
Synchronizing Parent and Child Workflows
If for some reason your parent workflow needs to wait for child workflows to complete, you can add a While activity with a condition to implement a check-and-delay loop:
To wait for the child workflows to finish, set the Duration property of the Delay activity to the amount of time you wish to wait before checking again to see if the child jobs are done.
appRules includes several options for managing and synchronizing parent/child processes. Select the option that works best for you to optimize processing and capture the necessary reporting details.
You can download appRules with sample projects at: http://www.appstrategy.com/appRulesTrial