Parallel branches

Parallel branches

Parallel branches

Introduction

In version 1.5, we added the possibility to define and use forks (parallel processes). Each fork is define a sub-process.
In this article, I will explain how to define, use and control parallel branches of workflow.
We will base ourselves on the example from the article Alternative to Windows Workflow Foundation.

Warning: with the free license of WFE the functional isn't work. It's require more limits of scheme. The sample have TRIAL license key that allow use this functionality.

Terms of parallel branches

For parallel branches we are added some flags to Transitions.

  • Is forkA transition with this flag starts or ends a subprocess.
  • Merge subprocess via set state - Merging a parent process and a subprocess occurs via set the current activity of the parent process to the final activity of the subprocess.
  • Disable parent process control - Disable auto-removing of a subprocesses if a parent process was set to an activity where the subprocess can not exist.

Create a scheme

Let's creating scheme of process with a root process and two subprocess.

Commands:

  • approve - for direct transition of main branch
  • denied - for reverse transition of main branch
  • rollback - for subprocess rollback
  • fastapprove - for subprocess fastapprove

Root process

Activities:

  • Dtaft
  • MainState1
  • MainState2
  • Final

Create transitions between activities. For direct transition to use "approve" command. For reverse - 'denied'.

Subprocess "RollBack"

Process for execute roll back. 

Activities:

  • Rollback

Starts from MainState1 activity and have two transitions:

The incoming transition

  • Type: AA
  • Classifier: NotSpecified
  • Is fork: true

The outcoming transition

  • Type: AC
  • Classifier: Direct
  • Trigger type: Command
  • Comand: rollback
  • Is fork: true
  • Merge subprocess via set state: true

Subprocess "FastApprove"

Process for execute fast approve and to change state of main process to Final.

Activities:

  • FastApprove

Starts from Draft activity and have two transitions:

The incoming transition

  • Type: AA
  • Classifier: NotSpecified
  • Is fork: true

The outcoming transition

  • Type: AC
  • Classifier: Direct
  • Trigger type: Command
  • Comand: fastapprove
  • Is fork: true
  • Merge subprocess via set state: true

In the result, you should receive the following scheme: scheme.txt.

Test

Operation:
0 - CreateInstance
1 - GetAvailableCommands
2 - ExecuteCommand
3 - GetAvailableState
4 - SetState
5 - DeleteProcess
9 - Exit
The process isn`t created.
CreateInstance - OK.
ProcessId = 'c3b6c1c2-a2b8-4ae0-b208-72351cdc9f43'. CurrentState: Draft, CurrentActivity: Draft
Enter code of operation:2
Available commands:
- approve (LocalizedName:approve, Classifier:Direct)
- fastapprove (LocalizedName:fastapprove, Classifier:Direct)
Enter command:approve
ExecuteCommand - OK.

ProcessId = 'c3b6c1c2-a2b8-4ae0-b208-72351cdc9f43'. CurrentState: MainState1, CurrentActivity: MainState1
Enter code of operation:2
Available commands:
- approve (LocalizedName:approve, Classifier:Direct)
- denial (LocalizedName:denial, Classifier:Reverse)
- rollback (LocalizedName:rollback, Classifier:Reverse)
- fastapprove (LocalizedName:fastapprove, Classifier:Direct)
Enter command:fastapprove
ExecuteCommand - OK.

ProcessId = 'c3b6c1c2-a2b8-4ae0-b208-72351cdc9f43'. CurrentState: Final, CurrentActivity: Final
Enter code of operation:4
Available state to set:
- Draft
- MainState1
- MainState2
- Final
Enter state:draft
SetState - OK.

ProcessId = 'c3b6c1c2-a2b8-4ae0-b208-72351cdc9f43'. CurrentState: Draft, CurrentActivity: Draft
Enter code of operation:2
Available commands:
- approve (LocalizedName:approve, Classifier:Direct)
- fastapprove (LocalizedName:fastapprove, Classifier:Direct)
Enter command:approve
ExecuteCommand - OK.

ProcessId = 'c3b6c1c2-a2b8-4ae0-b208-72351cdc9f43'. CurrentState: MainState1, CurrentActivity: MainState1
Enter code of operation:2
Available commands:
- approve (LocalizedName:approve, Classifier:Direct)
- denial (LocalizedName:denial, Classifier:Reverse)
- rollback (LocalizedName:rollback, Classifier:Reverse)
- fastapprove (LocalizedName:fastapprove, Classifier:Direct)
Enter command:approve
ExecuteCommand - OK.

ProcessId = 'c3b6c1c2-a2b8-4ae0-b208-72351cdc9f43'. CurrentState: MainState2, CurrentActivity: MainState2
Enter code of operation:2
Available commands:
- approve (LocalizedName:approve, Classifier:Direct)
- denial (LocalizedName:denial, Classifier:Reverse)
- rollback (LocalizedName:rollback, Classifier:Reverse)
- fastapprove (LocalizedName:fastapprove, Classifier:Direct)
Enter command:rollback
ExecuteCommand - OK.

ProcessId = 'c3b6c1c2-a2b8-4ae0-b208-72351cdc9f43'. CurrentState: Draft, CurrentActivity: Draft

Total

The new functionality broadens use of WFE, so now you can create more complex schemes.

  • By Dmitry Melnikov
  • 5/12/2015
  • Parallel branches, sub, parallel process, subprocess, fork, parallel fork