Process managers are in general reactive since they often live in an Event Driven Architecture (EDA) Vaughn Vernon explains describing how to build a reactive process manager with a focus on the reactive part, using Actor model for the implementation.
Vaughn Vernon, author of Implementing Domain-Driven Design, describes a process manager as sitting in the centre managing different components involved in a process, the example used by Vaughn is the process of obtaining a quote for a home loan.
In his example Vaughn is creating a process manager supervising finding the best loan quotes from banks for an individual, the process manager beeing a Loan broker in the example. Other major components are a Process entity actor holding the state of the process, a Credit bureau actor which decides if the individual is qualified for a loan, and a number of Bank actors from which quotes are asked.
Current state is kept in the Process entity actor, outside of the Process manager; a basic principle in actor model is to look for every opportunity for concurrency, i.e. to create a new actor. It also allows the Process manager to focus just on the process, not on the current state and also adheres to the Single Responsibility Pattern (SRP).
Starting the process is a command message “Quote best loan rate”, followed by a "Process started” event message and then a “Start loan rate quote” command message followed by a “Loan rate quote started” event message. The whole process ends with a “Loan rate best quote filled” message. Basically this is a request – reply pattern repeated several times.
Vaughn notes that the Loan broker has a lot of logic and compares it to commercial business process management tools with the main difference, besides cost, being that the Loan broker is specifically built for its purpose, not using any business level tools or language to describe the process.
To simplify making actor model diagrams, which he uses in his presentation, Vaughn has collaborated with Typesafe to create a set of standard actor model elements. The basic elements are for actors and messages, other elements depict creation and termination of actors and an actor’s lifeline.
Vaughn has written his example in C# using his recently published Dotsero, a toolkit that closely follows the Akka API, and which also includes the example code. The toolkit differs in approach to the one taken in Microsoft’s Orleans framework.
His example in Scala using Akka will be released together with the new book he is writing: Reactive Enterprise with Actor Model.