I am creating a system where users will be able to subscribe to events, and get notified when the event has occured. Example of events can be phone call durations and costs, phone data traffic notations, and even stock rate changes.
Example of events:
- customer 13532 completed a call with duration 11:45 min and cost $0.4
- stock rate for Google decreased with 0.01%
Customers can subscribe to events using some simple rules e.g.
- When stock rate of Google decreases more than 0.5%
- When the cost of a call of my subscription is over $1
Now, as the set of different rules is currently predefined, I can easily create a custom implemention that applies rules to an event. But if the set of rules could be much larger, and if we also allow for custom rules (e.g. when stock rate of Google decreses more than 0.5% AND stock rate of Apple increases with 0.5%), the system should be able to adapt. I am therefore thinking of a system that can interpret rules using a simple grammer and then apply them.
After some research I found that there exists rule-based engines that can be used, but I am unsure if they fit our need as they seem more appropriate for business logic, as hinted in Does Your Project Need a Rule Engine and Jess guildelines.
Is there a open source Java framework suited for this area? If anyone can point me to the correct direction, or recommend some system, that would be great!
Edit:
Thoughts for custom solution: I am thinking of using an event-to-rule mapping, where each rule is assosicated with a set of events. Then, when an event occurs, I know what rules that can be applied. If each rule is represented by is own class, then triggering the rule is simply to execute the class.
Pros: Simple and easy implementation. No need for interpretation of events to find rules
Cons: Each new rule requires coding. Cannot do deduction analysis.
If you see any major flaws in this approach please do tell me!