码迷,mamicode.com
首页 > 其他好文 > 详细

Rule Or WorkFlow

时间:2014-12-09 01:51:12      阅读:206      评论:0      收藏:0      [点我收藏+]

标签:des   http   io   ar   os   for   on   art   cti   

The main value of a Workflow engine is that it makes it possible to customize the flows through some workflow definition DSL. If you don‘t need to allow users to define their own arbitrary workflows, they you are better off just building your own.

Also workflow engines usually give you the ability to define business transactions & rules that are very long running. For example, you can have a workflow for authorizing purchase orders, where the first step is to enter some information about what needs to be purchased, then you have rules along the lines if the purchase is for less $100 okay it right away, if its between $100 & $2000 line manager can okay, if it‘s more then send it to some one else for approval ... etc. These types of business rules tend to change over the years as the amounts get increased, or the business policies for a company change. So it makes sense to use a workflow engine in those scenarios. Other good examples of complex business transactions that can benefit from a workflow engine are making an insurance claim, authorizing a loan or a mortgage, assessing a credit application from a customer ... etc. These business transactions tend to go through several people / departments and take several hours to days or weeks to complete.

Rule engines are good for extracting complex but changing rules from an application. Lets say you are an online retailer that ships to customer in the USA, Canada, UK, Germany, and France. You are required to charge taxes on the products you sell on your online shop but the rules for calculating taxes are different from country to country and from province to province within a country. Also some things are exempt from tax in one province but not in other provinces. Rule engines are great for these types of complex business rules that can change whenever the government changes their tax policy. Rules engines can give you an answer right way you just have to go to the rule engine say I want to run rule #10 and here are the inputs for rule #10 x,y,z and you get back an answer.

Main differences between a rule engine and a workflow engine, is that rule engine does not track the state of the transaction, it should be stateless working only on the inputs you provide it. Workflow engine is statefull, it must know what current state is the workflow in and must save that state to a database. Workflow engines also wait for input from external sources such as people or systems.

From what you are describing about your app I would just write some groovy classes to compute the next state of a ticket and make sure that the class is well documented and easy to update in a few years. I think rule engines and workflow engines are overkill for your situation, the amount of time it would take you to set them up and use them is much bigger that it would take you to write the code in groovy. If over time you discover you need the complexity of rule engines and workflow engines, I would pay the price then rather than now, keeping it simple is always the best choice.

http://www.infoq.com/articles/Rule-Engines

Rule Or WorkFlow

标签:des   http   io   ar   os   for   on   art   cti   

原文地址:http://www.cnblogs.com/diyunpeng/p/4152305.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!