问题
I was considering using Drools Fusion to implement the following exemplary rules:
- if customer bought two same products within a year, she gets third for free
- for spending more than 200 USD in at most three consecutive transactions customer gets a discount
- when the customer is inactive for more than a year a reminder is generated
- a supervisor is notified when a single order is greater than an average order value within last six monhts
- ...and so on, these are just examples from the top of my head
All these rules can be easily expressed using Drools Fusion. However after creating a prototype and reviewing the documentation it seems like this product is better suited for short-term, transient events (stock market, real-time decision making).
The question is: is it required to store all events in memory? (possibly millions of very old purchases). Moreover can Drools Fusion store events so that they survive server restart? (Ideally in the database).
I know Drools Fusion events are simply facts in Drools Expert, so maybe the question can be expanded to: can Drools Expert persist and lazily load facts?
回答1:
What you can do is to load the history information per customer each time that you get a new transaction for that customer. Or periodically load the information to review inactive customers. All the examples that you mention looks like Facts to me. Obviously that you can model everything as events, but as you mention that will cause that you will need to have everything in memory. To answer your question about store/handle million of events, you first need to answer the question if the JVM will support to have all those objects in memory.
Cheers
来源:https://stackoverflow.com/questions/8509993/drools-fusion-support-for-persistent-long-running-events