I am working for a school district, and we are planning on using Drools to implement the following types for rules for the student population of the districts constituent schools:
- If a student has 3 absences during a year their attendance metric moves to a WARN status.
- If a student has 6 absences during a year their attendance metric moves to a CRITICAL status.
- If a student has 3 major behavior incidents during a year their behavior metric moves to a WARN status.
- If a student has 2 minor and 2 major behavior incidents during a year their behavior metric moves to a CRITICAL status.
- ...these are just examples from the top of my head, but there are many more rules of a similar nature.
All of these rules can be simply expressed using Drools expert. Also, the processing of the rules for a student does not need to be synchronous. I have a couple of questions about the best way to implement this.
From one standpoint this could be viewed a monitoring system for a stream of events. This made me think of creating a stateful session into which each new event would be inserted. However, the events happen over the course of 9 months and are relatively infrequent. Also, we could build a session per school, or a session per student.
- Would keeping a session in memory for that long be a problem?
- If the server failed, would we need to rebuild the session state from scratch or would it be advisable to take regular snapshots and just restore the facts that occurred since the time of the snapshot.
Another option would be to persist a session for each student after an event is processed for that student. When the next event comes in we would retrieve their session from storage and insert the new fact. This way we wouldn't need to retrieve all the facts for each run of the engine to get the student's status. Would a configuration like this be supported? Are there any cons to doing this?
A third approach would be to respond to a new fact for a student by retrieving all other facts the rules need to run, create a new KnowledgeSession and run the rules.
Any advice on what might be the best approach would be greatly appreciated.
Dave