4

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?

Vignesh
  • 79
  • 2
  • 5
  • 3
    you appear to have fallen in the trap of thinking that everything is solved by a design pattern. Tell us what design you have come up with.... – Mitch Wheat Feb 16 '12 at 10:04
  • I was thinking of having a Rules Engine object which passes all streams though a queue . where the first in chain is filtering ,second is modifying and third is partitioning. – Vignesh Feb 16 '12 at 10:12
  • If a particular operation has not been configured for a stream, it simply passes the stream to the next in pipeline . This means I am statically configuring the rules engine for all the 3 operations always.Wondering if there is a way to configure the assembly line for the stream dynamically picking and choosing operations as needed for that particular stream – Vignesh Feb 16 '12 at 10:15
  • 2
    @MitchWheat: That isn't a trap, it is itself a design pattern: the Design Pattern Pattern. – Justin ᚅᚔᚈᚄᚒᚔ Feb 16 '12 at 16:44

1 Answers1

5

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 (i.e., 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.

Edson Tirelli
  • 3,891
  • 20
  • 23