There are technologies that support workflows for software systems like,
Windows Workflow Engine (WWF),
JBPM (in the open source. Tough learning curve though!)
but what if you wanted to do the same without any of the above technologies?
Tips
Windows Workflow Engine (WWF),
JBPM (in the open source. Tough learning curve though!)
but what if you wanted to do the same without any of the above technologies?
The options I could think of were,
- To use a design pattern like the state machine
- To use Windows services
The approach is what I would like to highlight here more than code.
Of-course the choice of technology would depend on the kind of project, the complexity of the workflows being handled and so on. But normally every software system does have some workflow associated.
For instance, say an Exit and Clearance Approval system for a small to mid-sized software company. It must be approved by the manager first, then goes for the clearance by the IT department, the Admin Department, then HR. It is important that the approval must go in the above sequence and should be tracked through software.
For instance, say an Exit and Clearance Approval system for a small to mid-sized software company. It must be approved by the manager first, then goes for the clearance by the IT department, the Admin Department, then HR. It is important that the approval must go in the above sequence and should be tracked through software.
This is one of the simplest examples I could think of. But in a more complex scenario like a VFx company; which apparently works on a shot that passes from department to department, would use a much complex workflow.
- State machine pattern can get complex with complex workflows.
- I have also worked on complex VFx workflows where we opted for Workflow Foundation (anyways we had to customize it a lot actually)
- JBPM is one other technology which fascinated us because it was an open source.
Though I must confess to have opted for Windows services, which was simple traceable and has worked for a couple of years and for about 30+ customers now.
Firstly, if you are new to Windows Services, please refer to this link on Code Project for a step by step walk-through. Steps are pretty much the same for whatever versions of Visual Studio used above VS 2005 also.
A simple approval system which consists of multiple levels of approval and sharing of content in the form of files is shown below
- A workflow processes an input and produces one or more outputs.
- Input / Output could be some content in the form of files dropped into a folder which is watched by a windows service. This folder can be called a watch folder.
- Input / Output could also be a database tables which are looked into for particular status or pre-conditions.
The Process
Say this is a case for the approval of VFx shot changes. The artist makes the changes, the supervisor reviews it approves / rejects it. The input to the next level of approval is the VFx shot (content) in a folder and a database approval status update.
- The user uploads his shot changes through the web portal.This triggers a database update. Status = Uploaded
- A windows service in the background keeps watching the database for records with Status=Uploaded. Once a matching record is found, it will trigger underlying business logic and put the content into a folder (watch folder) and also update the status in the database. Status = Approved By Supervisor
- A windows service in the background would be watching the folder (watch folder) in which the shot changes exist and the database tables for the Status = Approved By Supervisor to trigger the next set of operations and put the content and update the status for processing by the next windows service in line.
The steps in this workflow could be as many as possible.
Tips
- It is recommended that a base framework is written to handle logging and error handling to track the workflow properly.
- At every step of the service, a text file should be created as a log of steps of the service. This can help in the event of support issues. This is important, as it is not possible to debug a windows service by doing a F5, and it would be a nightmare issues happen in production environment.
Eg: [Fri 5 JUL 2013 1:10:00:00]Moving the file to destination folder E:\NextDeptWatch\ShotFile.m2t
[Fri 5 JUL 2013 1:10:00:00]File moved to destination successfully
- In case of issues, the log file with messages like above would be useful for the developer to trace where the code has failed and the entire stack trace of the the exception that occurred.
- The OnStart() and OnStop() need to be handled to process the content of the watch folders or database table contents.
Hope this helps while making a choice of architecture and technology to be used for your projects.