Search code examples
coldfusionworkflowbusiness-process-managementworkflow-engine

How do you model a business workflow in ColdFusion?


Since there's no complete BPM framework/solution in ColdFusion as of yet, how would you model a workflow into a ColdFusion app that can be easily extensible and maintainable?

A business workflow is more then a flowchart that maps nicely into a programming language. For example:

How do you model a task X that follows by multiple tasks Y0,Y1,Y2 that happen in parallel, where Y0 is a human process (need to wait for inputs) and Y1 is a web service that might go wrong and might need auto retry, and Y2 is an automated process; follows by a task Z that only should be carried out when all Y's are completed?

My thoughts...

  • Seems like I need to do a whole lot of storing / managing / keeping track of states, and frequent checking with cfscheuler.
  • cfthread ain't going to help much since some tasks can take days (e.g. wait for user's confirmation).
  • I can already image the flow is going to be spread around in multiple UDFs, DB, and CFCs
  • any opensource workflow engine in other language that maybe we can port over to CF?

Thank you for your brain power. :)


Solution

  • Study the Java Process Definition Language specification where JBoss has an execution engine for it. Using this Java based engine may be your easiest solution, and it solves many of the problems you've outlined.

    If you intend to write your own, you will probably end up modelling states and transitions, vertices and edges in a directed graph. And this as Ciaran Archer wrote are the components of a State Machine. The best persistence approach IMO is capturing versions of whatever data is being sent through workflow via serialization, capturing the current state, and a history of transitions between states and changes to that data. The mechanism probably needs a way to keep track of who or what has responsibility for taking the next action against that workflow.

    Based on your question, one thing to consider is whether or not you really need to represent parallel tasks in your solution. Where instead it might be possible to en-queue a set of messages and then specify a wait state for all of those to complete. Representing actual parallelism implies you are moving data simultaneously through several different processes. In which case when they join again you need an algorithm to resolve deltas, which is very much a non trivial task.

    In the context of ColdFusion and what you're trying to accomplish, a scheduled task may be necessary if the system you're writing needs to poll other systems. Consider WDDX as a serialization format. JSON, while seductively simple, I recall has some edge cases around numbers and dates that can cause you grief.

    Finally see my answer to this question for some additional thoughts.