Web services are used by a complex business process that runs for minutes, hours, days, or weeks.
How can web services be used to support complex and long-running business processes?
Web services are often used to launch complex business processes that run for extended periods of time. A web service may, for example, trigger tasks that reserve flights, hotels, and car rentals for a vacation package. Processes like these can take several minutes, hours, or even days to complete. If the service implements all of the logic required to process requests like these, then it may remain in server memory for a very long time. The problem is that services like these do not scale well with increased load. If the web service or server crashes, the service may lose the client's request, and information in the underlying systems may be left in an inconsistent state.
Developers could create custom software infrastructures to manage complex business processes like these. These infrastructures must know how and when to instantiate a logical business process, and what conditions cause the process to terminate. Issues like task execution, variable state management, exception handling, retries, task compensation, failover, load balancing, and resource optimization must also be addressed. Most businesses would be wise to refrain from building such infrastructures.
Use a workflow engine to manage the life cycle and execution of tasks within complex or long-running business processes. Identify a web service that will trigger each logical business process. Use callback services to receive additional data for these long-running processes, and forward messages from these callback services to the workflow engine.
Workflow engines govern entire workflow life cycles from process instantiation to termination. They trigger task execution, and, for each process instance, keep track of which tasks are executing, which are waiting or suspended, and which must be resumed or restarted. Many workflow engines save the state of tasks and variables to a database before and after tasks are executed.
The Workflow Connector pattern uses web services as a means to launch business processes managed by workflow engines. Developers designate a Trigger service that creates new process instances for a given process definition. Callback Services may also be designated to receive additional data after the process has started. The workflow engine ensures that each callback message is routed back to the correct process instance.
A sizable pattern language has been compiled for workflow. The Workflow Patterns catalogue, for example, organizes workflow concepts into Control-Flow, Data, Resource, and Exception-Handling patterns.