tag:blogger.com,1999:blog-5869426.post2784860261037637409..comments2024-01-16T10:48:25.428+00:00Comments on Drools & jBPM: Drools Quick Start - Stateful Knowledge SessionMark Proctorhttp://www.blogger.com/profile/03304277188725220501noreply@blogger.comBlogger7125tag:blogger.com,1999:blog-5869426.post-42517851179153525332019-10-03T08:39:19.515+01:002019-10-03T08:39:19.515+01:00It is a great website.. The Design looks very goo...It is a great website.. The Design looks very good.. Keep working like that!. <br /><a href="http://gextonsecurity.com" rel="nofollow">Fire Alarm Security System</a>james johnhttps://www.blogger.com/profile/16587939241096475733noreply@blogger.comtag:blogger.com,1999:blog-5869426.post-8093854790060547402011-04-26T07:33:01.090+01:002011-04-26T07:33:01.090+01:00Hi Mark,
If I am inserting an array into knowledg...Hi Mark,<br /><br />If I am inserting an array into knowledgebase, how do I write a rule to check if this array contains a specific element?<br />ex. StatefulKnowledgeSession session;<br />Person[] persons = new Person[10];<br />session.insert(persons);<br /><br />Now I want to write a rule to check if Person ( name = "Mark" ) exists in persons.<br /><br />Thank youAnonymoushttps://www.blogger.com/profile/01935428116307678546noreply@blogger.comtag:blogger.com,1999:blog-5869426.post-82445652342120221612009-04-09T21:09:00.000+01:002009-04-09T21:09:00.000+01:00Hi, Just one small observation: The example consol...Hi, Just one small observation: The example console output following the retractions should read "Turn off the sprinkler for room XXX". Otherwise it reads fine. With kind regards, MikeAnonymoushttps://www.blogger.com/profile/06581771208570261964noreply@blogger.comtag:blogger.com,1999:blog-5869426.post-42962783378181397952009-04-09T17:28:00.000+01:002009-04-09T17:28:00.000+01:00That is better. Thank you!That is better. Thank you!Michal Balihttps://www.blogger.com/profile/16415352346106854117noreply@blogger.comtag:blogger.com,1999:blog-5869426.post-52298617383177761302009-04-09T16:40:00.000+01:002009-04-09T16:40:00.000+01:00Thanks for the feedback, I've updated the blog and...Thanks for the feedback, I've updated the blog and the docs this was derived from. I didn't add the constructor info, as I expect most people to realise that and I want to keep the code snippets compact. If we get a lot of confusion, I'll update it for constructors.<BR/><BR/>I update the stateless info with regards to inference and sequential, please let me know if that's better.Mark Proctorhttps://www.blogger.com/profile/03304277188725220501noreply@blogger.comtag:blogger.com,1999:blog-5869426.post-28752658103583509682009-03-31T15:40:00.000+01:002009-03-31T15:40:00.000+01:00Hi,"Stateless sessions do not have inference, so t...Hi,<BR/>"Stateless sessions do not have inference, so the engine does not need to be aware of changes to data, however a stateful session<BR/>does" <BR/>Should it say: "Stateless sessions in *sequential mode* do not have inference..."? Because by default stateless session has inference it just doesn't keep state between execute calls. Or is this meant to be an implementation detail that nobody should depend on?<BR/>BTW the API says: "StatelessKnowledgeSessions are convenience api, that wraps a StatefulKonwledgeSession. It removes the need to call dispose()..."<BR/>Best Regards,<BR/>MichalMichal Balihttps://www.blogger.com/profile/16415352346106854117noreply@blogger.comtag:blogger.com,1999:blog-5869426.post-29410516503615938482009-03-30T13:59:00.000+01:002009-03-30T13:59:00.000+01:00Thanks for the example Mark, very helpful. I found...Thanks for the example Mark, very helpful. I found a couple of typos when I tried to run it up, and offer these comment to help other people get the example up an running more speedily:<BR/><BR/>public class Fire {<BR/> private room room; <BR/>[should be Room room]<BR/><BR/><BR/> // getter and setter methods here<BR/>[could mention that Room needs a constructor that takes room name, and Sprinkler and Fire each need a constructor that takes a Room instance]<BR/><BR/><BR/> modify( $sprinkler ) { setOn( true ) };<BR/> System.out.println( "Turn off the sprinkler for room " + $room.getName() );<BR/>[should be "Turn on the sprinkler for room "]<BR/><BR/><BR/>rule "When the fire is gone turn on the sprinkler"<BR/>[should be "When the fire is gone turn off the sprinkler"]<BR/><BR/><BR/>FactHandle kitchenFireHandle = kession.insert( kitchenFire );<BR/>[should be FactHandle kitchenFireHandle = ksession.insert( kitchenFire );]<BR/><BR/><BR/>ksession.retract( kitchenFire );<BR/>ksession.retract( officeFire );<BR/>[should be ksession.retract( kitchenFireHandle );<BR/>ksession.retract( officeFireHandle );]<BR/><BR/>Also I found that I had to give the two rules "Raise the alarm when we have one or more fires" and "Lower the alarm when all the fires have gone" explicit salience values to get them to fire before the "When there is a fire turn on the sprinkler" and "When the fire is gone turn off the sprinkler" so as to get the output in this order:<BR/><BR/>Everything is ok<BR/>Raise the alarm<BR/>Turn on the sprinkler for room office<BR/>Turn on the sprinkler for room kitchen<BR/>Lower the alarm<BR/>Turn off the sprinkler for room office<BR/>Turn off the sprinkler for room kitchen<BR/>Everything is okJohn Snoreply@blogger.com