Re: [rules-users] Maintaining DB/Working Memory Synchronization
I was just referring to facts that we're being placed into your statefulknowledgesession. As I mentioned, I use a mechanism with an EJB to manage my JPA entities before injecting them into the session. I passed on a blog entry with a ruleflow example as that looks to do a similar thing but within drools, and I would be interested to hear how such an implementation would go. KnowledgeBase (compiled rules) and StatefulSessions (facts) are stored and serialized independently, btw. best wishes, Andrew 2009/11/8 Nestor Tarin Burriel > So, Do you mean that for serializing the state of a > StatefulKnowledgeSession we must include our rules into a ruleflow? How do > you upgrade your KnowledgeBase without loosing the WM state? > > Please check this issues: > > https://jira.jboss.org/jira/browse/JBRULES-1946 > > https://jira.jboss.org/jira/browse/JBRULES-2278 > > Nestor > > 2009/11/7 Andrew Waterman > > It can depend on how you want to use working memory as well. If you are >> working statelessly, you can load objects through some type of transactional >> framework, insert them into memory (or the ones relevant to you at that >> moment in time) let Drools evaluate the objects, make changes and then >> serialize those changes once rules have stopped firing. I do something like >> this using EJB and JPA. I've been interested in pushing this into the rules >> themselves; which I believe is now possible using the JPA support within >> Drools flow. This might work much better if you were using statefull and >> long running working memory process. Even in the event of catastrophic >> failure, your transactionally serialized changes would still remain in the >> database. So you could restart and pick up work from where you were last. >> >> You may wish to take a look at the following blog entries: >> >> http://blog.athico.com/2009/03/drools-50-cr1-new-and-noteworthy.html >> >> And the Drools flow documentation. >> >> I'm hoping to move our work in this direction so please do pass on your >> results; unless I'm completely misunderstanding how one can use flow, expert >> and JPA together with transactions. >> >> best wishes, >> >> Andrew >> >> On Sat, Nov 7, 2009 at 9:23 AM, ken.p wrote: >> >>> >>> I am also looking similar feature. We can currently use AOP to send event >>> to >>> stream. However, we have events with relevant duration for days and some >>> time weeks. If server were to restart for maintenance, how do we restore >>> to >>> the same state? >>> >>> >>> >>> Daniel Miller-9 wrote: >>> > >>> > So I hope that someone out here, or many of you, can give me some idea >>> > of how you do this. >>> > >>> > I have about 20+ entities in my database that I want Drools to know >>> > about. Obviously my hope is to apply CEP, rules and processes to >>> > these items. However, I feel like I'm missing some type of connection >>> > between how Drools recommends keeping my working memory in sync with >>> > my database changes. >>> > >>> > Ideally, I'd love to be able to just update my entities as I have been >>> > doing in the database, but have those changes automatically move their >>> > way over into the working memory. How do any of you recommend I >>> > accomplish this? >>> > >>> > Thanks in advance for any suggestions. >>> > >>> > Dan Miller >>> > >>> > ___ >>> > rules-users mailing list >>> > rules-users@lists.jboss.org >>> > https://lists.jboss.org/mailman/listinfo/rules-users >>> > >>> > >>> >>> -- >>> View this message in context: >>> http://old.nabble.com/Maintaining-DB-Working-Memory-Synchronization-tp26238313p26241138.html >>> Sent from the drools - user mailing list archive at Nabble.com. >>> >>> ___ >>> rules-users mailing list >>> rules-users@lists.jboss.org >>> https://lists.jboss.org/mailman/listinfo/rules-users >>> >> >> >> >> -- >> +1 510 342 5693 >> >> PO Box 7775 #8750 >> San Francisco, California 94120-7775 >> >> "Warning: following standard input indefinitely is ineffective" >> - /bin/tail error message >> >> "Against logic there is no armor like ignorance." >> - Laurence J. Pete >> >> ___ >> rules-users mailing list >> rules-users@lists.jboss.org >> https://lists.jboss.org/mailman/listinfo/rules-users >> >> > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > > -- +1 510 342 5693 PO Box 7775 #8750 San Francisco, California 94120-7775 "Warning: following standard input indefinitely is ineffective" - /bin/tail error message "Against logic there is no armor like ignorance." - Laurence J. Pete ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Maintaining DB/Working Memory Synchronization
So, Do you mean that for serializing the state of a StatefulKnowledgeSession we must include our rules into a ruleflow? How do you upgrade your KnowledgeBase without loosing the WM state? Please check this issues: https://jira.jboss.org/jira/browse/JBRULES-1946 https://jira.jboss.org/jira/browse/JBRULES-2278 Nestor 2009/11/7 Andrew Waterman > It can depend on how you want to use working memory as well. If you are > working statelessly, you can load objects through some type of transactional > framework, insert them into memory (or the ones relevant to you at that > moment in time) let Drools evaluate the objects, make changes and then > serialize those changes once rules have stopped firing. I do something like > this using EJB and JPA. I've been interested in pushing this into the rules > themselves; which I believe is now possible using the JPA support within > Drools flow. This might work much better if you were using statefull and > long running working memory process. Even in the event of catastrophic > failure, your transactionally serialized changes would still remain in the > database. So you could restart and pick up work from where you were last. > > You may wish to take a look at the following blog entries: > > http://blog.athico.com/2009/03/drools-50-cr1-new-and-noteworthy.html > > And the Drools flow documentation. > > I'm hoping to move our work in this direction so please do pass on your > results; unless I'm completely misunderstanding how one can use flow, expert > and JPA together with transactions. > > best wishes, > > Andrew > > On Sat, Nov 7, 2009 at 9:23 AM, ken.p wrote: > >> >> I am also looking similar feature. We can currently use AOP to send event >> to >> stream. However, we have events with relevant duration for days and some >> time weeks. If server were to restart for maintenance, how do we restore >> to >> the same state? >> >> >> >> Daniel Miller-9 wrote: >> > >> > So I hope that someone out here, or many of you, can give me some idea >> > of how you do this. >> > >> > I have about 20+ entities in my database that I want Drools to know >> > about. Obviously my hope is to apply CEP, rules and processes to >> > these items. However, I feel like I'm missing some type of connection >> > between how Drools recommends keeping my working memory in sync with >> > my database changes. >> > >> > Ideally, I'd love to be able to just update my entities as I have been >> > doing in the database, but have those changes automatically move their >> > way over into the working memory. How do any of you recommend I >> > accomplish this? >> > >> > Thanks in advance for any suggestions. >> > >> > Dan Miller >> > >> > ___ >> > rules-users mailing list >> > rules-users@lists.jboss.org >> > https://lists.jboss.org/mailman/listinfo/rules-users >> > >> > >> >> -- >> View this message in context: >> http://old.nabble.com/Maintaining-DB-Working-Memory-Synchronization-tp26238313p26241138.html >> Sent from the drools - user mailing list archive at Nabble.com. >> >> ___ >> rules-users mailing list >> rules-users@lists.jboss.org >> https://lists.jboss.org/mailman/listinfo/rules-users >> > > > > -- > +1 510 342 5693 > > PO Box 7775 #8750 > San Francisco, California 94120-7775 > > "Warning: following standard input indefinitely is ineffective" > - /bin/tail error message > > "Against logic there is no armor like ignorance." > - Laurence J. Pete > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Maintaining DB/Working Memory Synchronization
I neglected to mention my reply is from the viewpoint of changing entities through the program that interacts with drools; if you need to sense changes from another source to entities/tables in a database Greg's suggestion seems the easiest and least resource intensive. Pushed actions from the database into rules would be more efficient; but this begs the question as to where working memory is held; are you thinking of REST calls to a Drools rules server Greg? best wishes, Andrew On Sat, Nov 7, 2009 at 9:59 AM, Andrew Waterman wrote: > It can depend on how you want to use working memory as well. If you are > working statelessly, you can load objects through some type of transactional > framework, insert them into memory (or the ones relevant to you at that > moment in time) let Drools evaluate the objects, make changes and then > serialize those changes once rules have stopped firing. I do something like > this using EJB and JPA. I've been interested in pushing this into the rules > themselves; which I believe is now possible using the JPA support within > Drools flow. This might work much better if you were using statefull and > long running working memory process. Even in the event of catastrophic > failure, your transactionally serialized changes would still remain in the > database. So you could restart and pick up work from where you were last. > > You may wish to take a look at the following blog entries: > > http://blog.athico.com/2009/03/drools-50-cr1-new-and-noteworthy.html > > And the Drools flow documentation. > > I'm hoping to move our work in this direction so please do pass on your > results; unless I'm completely misunderstanding how one can use flow, expert > and JPA together with transactions. > > best wishes, > > Andrew > > On Sat, Nov 7, 2009 at 9:23 AM, ken.p wrote: > >> >> I am also looking similar feature. We can currently use AOP to send event >> to >> stream. However, we have events with relevant duration for days and some >> time weeks. If server were to restart for maintenance, how do we restore >> to >> the same state? >> >> >> >> Daniel Miller-9 wrote: >> > >> > So I hope that someone out here, or many of you, can give me some idea >> > of how you do this. >> > >> > I have about 20+ entities in my database that I want Drools to know >> > about. Obviously my hope is to apply CEP, rules and processes to >> > these items. However, I feel like I'm missing some type of connection >> > between how Drools recommends keeping my working memory in sync with >> > my database changes. >> > >> > Ideally, I'd love to be able to just update my entities as I have been >> > doing in the database, but have those changes automatically move their >> > way over into the working memory. How do any of you recommend I >> > accomplish this? >> > >> > Thanks in advance for any suggestions. >> > >> > Dan Miller >> > >> > ___ >> > rules-users mailing list >> > rules-users@lists.jboss.org >> > https://lists.jboss.org/mailman/listinfo/rules-users >> > >> > >> >> -- >> View this message in context: >> http://old.nabble.com/Maintaining-DB-Working-Memory-Synchronization-tp26238313p26241138.html >> Sent from the drools - user mailing list archive at Nabble.com. >> >> ___ >> rules-users mailing list >> rules-users@lists.jboss.org >> https://lists.jboss.org/mailman/listinfo/rules-users >> > > > > -- > +1 510 342 5693 > > PO Box 7775 #8750 > San Francisco, California 94120-7775 > > "Warning: following standard input indefinitely is ineffective" > - /bin/tail error message > > "Against logic there is no armor like ignorance." > - Laurence J. Pete > -- +1 510 342 5693 PO Box 7775 #8750 San Francisco, California 94120-7775 "Warning: following standard input indefinitely is ineffective" - /bin/tail error message "Against logic there is no armor like ignorance." - Laurence J. Pete ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Maintaining DB/Working Memory Synchronization
It can depend on how you want to use working memory as well. If you are working statelessly, you can load objects through some type of transactional framework, insert them into memory (or the ones relevant to you at that moment in time) let Drools evaluate the objects, make changes and then serialize those changes once rules have stopped firing. I do something like this using EJB and JPA. I've been interested in pushing this into the rules themselves; which I believe is now possible using the JPA support within Drools flow. This might work much better if you were using statefull and long running working memory process. Even in the event of catastrophic failure, your transactionally serialized changes would still remain in the database. So you could restart and pick up work from where you were last. You may wish to take a look at the following blog entries: http://blog.athico.com/2009/03/drools-50-cr1-new-and-noteworthy.html And the Drools flow documentation. I'm hoping to move our work in this direction so please do pass on your results; unless I'm completely misunderstanding how one can use flow, expert and JPA together with transactions. best wishes, Andrew On Sat, Nov 7, 2009 at 9:23 AM, ken.p wrote: > > I am also looking similar feature. We can currently use AOP to send event > to > stream. However, we have events with relevant duration for days and some > time weeks. If server were to restart for maintenance, how do we restore to > the same state? > > > > Daniel Miller-9 wrote: > > > > So I hope that someone out here, or many of you, can give me some idea > > of how you do this. > > > > I have about 20+ entities in my database that I want Drools to know > > about. Obviously my hope is to apply CEP, rules and processes to > > these items. However, I feel like I'm missing some type of connection > > between how Drools recommends keeping my working memory in sync with > > my database changes. > > > > Ideally, I'd love to be able to just update my entities as I have been > > doing in the database, but have those changes automatically move their > > way over into the working memory. How do any of you recommend I > > accomplish this? > > > > Thanks in advance for any suggestions. > > > > Dan Miller > > > > ___ > > rules-users mailing list > > rules-users@lists.jboss.org > > https://lists.jboss.org/mailman/listinfo/rules-users > > > > > > -- > View this message in context: > http://old.nabble.com/Maintaining-DB-Working-Memory-Synchronization-tp26238313p26241138.html > Sent from the drools - user mailing list archive at Nabble.com. > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > -- +1 510 342 5693 PO Box 7775 #8750 San Francisco, California 94120-7775 "Warning: following standard input indefinitely is ineffective" - /bin/tail error message "Against logic there is no armor like ignorance." - Laurence J. Pete ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Maintaining DB/Working Memory Synchronization
I am also looking similar feature. We can currently use AOP to send event to stream. However, we have events with relevant duration for days and some time weeks. If server were to restart for maintenance, how do we restore to the same state? Daniel Miller-9 wrote: > > So I hope that someone out here, or many of you, can give me some idea > of how you do this. > > I have about 20+ entities in my database that I want Drools to know > about. Obviously my hope is to apply CEP, rules and processes to > these items. However, I feel like I'm missing some type of connection > between how Drools recommends keeping my working memory in sync with > my database changes. > > Ideally, I'd love to be able to just update my entities as I have been > doing in the database, but have those changes automatically move their > way over into the working memory. How do any of you recommend I > accomplish this? > > Thanks in advance for any suggestions. > > Dan Miller > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > > -- View this message in context: http://old.nabble.com/Maintaining-DB-Working-Memory-Synchronization-tp26238313p26241138.html Sent from the drools - user mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Maintaining DB/Working Memory Synchronization
Greg Barton yahoo.com> writes: > > I don't think there's a built in way to do this with drools, but in general this is done using database > triggers. The trigger fires when the data changes, and from there it's up to you how the record is > transported to working memory. > > If you use oracle there's a specific mechanism for this called "Database Change Notification" > > --- On Fri, 11/6/09, Daniel Miller versatile.com> wrote: > > > From: Daniel Miller versatile.com> > > Subject: [rules-users] Maintaining DB/Working Memory Synchronization > > To: rules-users lists.jboss.org > > Date: Friday, November 6, 2009, 2:43 PM > > So I hope that someone out here, or > > many of you, can give me some idea > > of how you do this. > > > > I have about 20+ entities in my database that I want Drools > > to know > > about. Obviously my hope is to apply CEP, rules and > > processes to > > these items. However, I feel like I'm missing some > > type of connection > > between how Drools recommends keeping my working memory in > > sync with > > my database changes. > > > > Ideally, I'd love to be able to just update my entities as > > I have been > > doing in the database, but have those changes automatically > > move their > > way over into the working memory. How do any of you > > recommend I > > accomplish this? > > > > Thanks in advance for any suggestions. > > > > Dan Miller > > > > ___ > > rules-users mailing list > > rules-users lists.jboss.org > > https://lists.jboss.org/mailman/listinfo/rules-users > > > > ___ > rules-users mailing list > rules-users lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > > Thanks for the suggestion. So I did something similar, not using database triggers, but trying something I saw in a blog post. I modified my rule so that instead of loading the working memory and then firing the rules, the rule does something like this: rule when a : AssetRemote(assetType='Temperature Probe',removed=false) from assetService.getAllUndeletedAssets(); then //do some work here end "assetService" is my service class that does my query to the database and returns a List objects. This worked great -- except it only fired once. There are no objects in my working memory, but if I call fireAllRules(), this rule gets ignored the second, third, nth time it's fired. What am I missing? Before I was manually calling an update(a); in the "then" section to refresh the session on the object. But, since there are no objects using the from method, I don't know how to refresh the session so that this rule will fire each time fireAllRules() is called. Keep the suggestions coming though. Thanks, Dan Miller ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Maintaining DB/Working Memory Synchronization
org.drools.event.WorkingMemoryEventListener would be the other option, now using changes to the Working Memory as the trigger to update the Data Base. If you intend using rules that modify WM contents, you may have to have this in addition to a DB change notification mechanism.-W On Fri, Nov 6, 2009 at 9:43 PM, Daniel Miller wrote: > So I hope that someone out here, or many of you, can give me some idea > of how you do this. > > I have about 20+ entities in my database that I want Drools to know > about. Obviously my hope is to apply CEP, rules and processes to > these items. However, I feel like I'm missing some type of connection > between how Drools recommends keeping my working memory in sync with > my database changes. > > Ideally, I'd love to be able to just update my entities as I have been > doing in the database, but have those changes automatically move their > way over into the working memory. How do any of you recommend I > accomplish this? > > Thanks in advance for any suggestions. > > Dan Miller > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users