c# - Can the Windows Workflow Rules Engine handle branching? -


i'm trying write c# application takes in hundreds of thousands of independent rows of data and, based on rules defined user, sets property. such i've thought of using rules engine. after googling, decided use in-built windows workflow foundation rules engine.

the interface creating rules presented user in pipe , filter style:

raw data -> rule1 -> if result rule 1 true, execute rule2 / if result rule 1 false, execute rule 3 -> ... branches of execution of other rules ... -> depending on branches taken, property set value.

i wish able execute rules in similar pipe , filter / branching style, not sequentially non-chaining ruleset does. not sure how create dependencies chaining ruleset match flow. realize wf has ifelse activities type of branching, support similar rules, workflow activities 2 orders of magnitude slower.

am using these technologies incorrectly ? (i new c#) should writing own rule engine ? advice appreciated.

edit: additional details research i've done. i've googled around , read blog posts / tutorials / msdn resources find in past week (no use linking, there's tons , used obvious keywords). rule engine ruleset seems exclusively used sequential independent rules, , when dependent, signal fact changing variable dependency in rule , causes rules re-evaluated (thorough similar rete called full-chaining believe). can't see way of inserting dependencies rules dynamically based on structure , relationship. can model flow of control ifelse activities.

i've implemented small ruleset 700 rows of sample data , ran few tests. (no use pasting in code, do't have issue that) evaluate in ~50 ms, while equivalent logic built ifelse activities , same rules evaluates in aprox. 2 seconds, guessing overhead of switching activities. either not using these technologies correctly (by mean not aware of property of rulesets evaluated hierharhically in exclusive branches, or faster switching activities) or there no easy way control flow of execution ruleset , must therefore incur large performance penalty activities. in case might write own rule engine.

edit 2: a diagram of flow of execution need ruleset

right, managed turn inherent sequential execution of rules hierarhical one.

this achieved using 1 additional external variable serves rule id next executed, , doubling number of rules (these "execution flow control" rules hidden user). doubles execution time, still acceptable when compared using ifelse activity. around 1000000 rows of data can processed in under minute.


structure of rule :

rule_n composed of 2 rules :

rule_n_1's condition : ruleidtobenextexecuted = n , (user's rule)

rule_n_1's evaluation true : ruleidtobenextexecuted = next action/rule if rule_n true

rule_n_1's evaluation false : no action taken.

rule_n_2's condition : ruleidtobenextexecuted = n , not(user's rule)

rule_n_2's evaluation true : ruleidtobenextexecuted = next action/rule if rule_n false

rule_n_2's evaluation false : no action taken.


equivalent diagram 1 in question : more states

this structure allows me create pipe&filter execution approach user's rules.

research : own data structure design.


Comments