简体   繁体   中英

Best Design pattern to create a rules engine

Suppose I have to design a rules engine , where depending on a static configuration rule, the chain of responsibility changes at runtime. What is the best design pattern for implementing this problem?

FOr e,g. depending on some configurations, a set of events in stream can be (1) filtered, (2) partitioned into subsets (3) modified

For each stream, customer can choose all of the 3 or some of the three or none of the three.

So, my assembly pipeline should be configured at runtime based on config for each stream.

WHich is the best design pattern to achieve this?

I am not sure I understand your use case, but there are open source projects that seem to do exactly what you need.

First of all, you have Apache Camel , that allows you to configure routes (statically and/or dynamically). This way you can route the event streams through each component of your pipeline according to the routes that are configured.

Alternatively or in addition to Camel, Drools Fusion and Esper are two open source projects that do Complex Event Processing (ie, event filtering, correlation, segregation, etc). They both support dynamic addition/removal of rules/queries. So instead of changing the route, you can for instance, have a single route into a Drools/Esper session and instead just add/remove rules/queries according to the configuration in order to do what you need.

It seems to me that you don't need to create a "rules engine". You can just use what is out there.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM