如何在 ColdFusion 中对业务工作流程进行建模?
由于 ColdFusion 中目前还没有完整的 BPM 框架/解决方案,您如何将工作流程建模到可轻松扩展和维护的 ColdFusion 应用程序中?
业务工作流程不仅仅是一个可以很好地映射到编程语言的流程图。例如:
如何对任务 X 进行建模,该任务 X 后面跟着并行发生的多个任务 Y0、Y1、Y2,其中 Y0 是人工流程(需要等待输入),Y1 是可能出错的 Web 服务需要自动重试,Y2是一个自动化过程;后面跟着一个任务 Z,只有当所有 Y 都完成后才应该执行?
我的想法...
- 似乎我需要做大量的存储/管理/保存 跟踪状态,并经常使用 cfscheuler 检查。
cfthread
不会有太大帮助,因为某些任务可能需要几天时间 (例如等待用户的确认)。- 我已经可以想象流量将分布在多个 UDF 中, DB 和 CFC
- 是否有其他语言的开源工作流引擎,也许我们可以移植到 CF?
谢谢你的脑力。 :)
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 withcfscheuler
. 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. :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
研究 Java 流程定义语言规范,其中 JBoss 有一个执行引擎。使用这个基于 Java 的引擎可能是最简单的解决方案,它解决了您概述的许多问题。
如果您打算自己编写,您可能最终会在有向图中对状态和转换、顶点和边进行建模。正如 Ciaran Archer 所写,这是状态机的组件。 IMO 的最佳持久性方法是通过序列化捕获通过工作流发送的任何数据的版本、捕获当前状态以及状态之间转换和数据更改的历史记录。该机制可能需要一种方法来跟踪谁或什么负责针对该工作流程采取下一步行动。
根据您的问题,需要考虑的一件事是您是否确实需要在解决方案中表示并行任务。相反,可以将一组消息排入队列,然后指定所有消息完成的等待状态。表示实际的并行性意味着您正在通过多个不同的进程同时移动数据。在这种情况下,当他们再次加入时,您需要一种算法来解决增量问题,这是一项非常重要的任务。
在 ColdFusion 的上下文中以及您想要完成的任务中,如果您正在编写的系统需要轮询其他系统,则可能需要计划任务。将 WDDX 视为一种序列化格式。 JSON 虽然非常简单,但我记得在数字和日期方面存在一些边缘情况,可能会让您感到悲伤。
最后查看我对此问题的回答以了解一些其他想法< /a>.
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.
我突然想到状态设计模式,状态持续到数据库。查看 Head First 设计模式 的口香糖机示例。
一般来说,如果您有一些东西(例如客户/订单/等)经历了多次状态变化,那么这将起作用。
根据您所处的状态,您的对象会发生不同的事情,这可能意味着坐在数据库表中等待用户手动更新标志。
就其他语言而言,我知道 Grails 有一个可用的 工作流模块。我不知道移植到 CF 或跳到 Grails 是否会更好(适合这项工作的工具等等)。
这只是一个想法,希望有帮助。
Off the top of my head I'm thinking about the State design pattern with state persisted to a database. Check out the Head First Design Patterns's Gumball Machine example.
Generally this will work if you have something (like a client / order / etc.) going through a number of changes of state.
Different things will happen to your object depending on what state you are in, and that might mean sitting in a database table waiting for a flag to be updated by a user manually.
In terms of other languages I know Grails has a workflow module available. I don't know if you would be better off porting to CF or jumping ship to Grails (right tool for the job and all that).
It's just a thought, hope it helps.