Re: [rules-users] Problem with Collection
Making the rules more complicated in order to achieve control over sending messages to some other application does not strike me as the best option. As an alternative, processed facts could be collected on the interface between Drools and your application A. -W On 13 April 2014 05:26, mohanm wrote: > Hi Laune, > > Drools is integrated to an application A which is communicating to another > application B through webservice. Based on the facts in the working memory > we are going to do send an request to Application B to do some action > either > create,update or delete existing events. All the calls to the Application B > is synchronous. If we have more and more requests going to Application B > through synchronous calls, Application B is taking time to process those > requests. we need to limit these calls as low as possible, Any faults at > device can generate more than 100 events which in turn converted in to > facts > and inserted into working memory. For each facts, I don't want to create > 100 > requests to Application B. I need to send only one request to Application B > for all the facts together, So we are using collection to control this. > > While using collection we were facing the problem as mentioned below. > > Hope I made you understand > > > > > > -- > View this message in context: > http://drools.46999.n3.nabble.com/Problem-with-Collection-tp4029219p4029227.html > Sent from the Drools: User forum mailing list archive at Nabble.com. > ___ > 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] Problem with Collection
Hi Laune, Drools is integrated to an application A which is communicating to another application B through webservice. Based on the facts in the working memory we are going to do send an request to Application B to do some action either create,update or delete existing events. All the calls to the Application B is synchronous. If we have more and more requests going to Application B through synchronous calls, Application B is taking time to process those requests. we need to limit these calls as low as possible, Any faults at device can generate more than 100 events which in turn converted in to facts and inserted into working memory. For each facts, I don't want to create 100 requests to Application B. I need to send only one request to Application B for all the facts together, So we are using collection to control this. While using collection we were facing the problem as mentioned below. Hope I made you understand -- View this message in context: http://drools.46999.n3.nabble.com/Problem-with-Collection-tp4029219p4029227.html Sent from the Drools: User forum 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] Problem with Collection
On 12 April 2014 12:57, mohanm wrote: > Hi laune, > > Number of facts inserted into the working memory will be high at times. > Events are facts for us. After first fact matching condition in the working > memory, we want to wait for few seconds to collect similar facts and do an > action on that. I still don't see a good reason for waiting and doing a collect. -W > when we changed any attribute on the facts in the > collection, the collection got refreshed. > > I tried copying the Collection to another Arraylist in java code, it didnt > work properly. I will try as per your suggestion to do in the RHS of the > rule. > > Is there a way to change the attributes of the facts in the collection and > then update all the facts belonging to particular class. > > Thanks for your reply and suggestion. > > Mohan > > > > -- > View this message in context: > http://drools.46999.n3.nabble.com/Problem-with-Collection-tp4029219p4029222.html > Sent from the Drools: User forum mailing list archive at Nabble.com. > ___ > 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] Problem with Collection
Hi laune, Number of facts inserted into the working memory will be high at times. Events are facts for us. After first fact matching condition in the working memory, we want to wait for few seconds to collect similar facts and do an action on that. when we changed any attribute on the facts in the collection, the collection got refreshed. I tried copying the Collection to another Arraylist in java code, it didnt work properly. I will try as per your suggestion to do in the RHS of the rule. Is there a way to change the attributes of the facts in the collection and then update all the facts belonging to particular class. Thanks for your reply and suggestion. Mohan -- View this message in context: http://drools.46999.n3.nabble.com/Problem-with-Collection-tp4029219p4029222.html Sent from the Drools: User forum 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] Problem with Collection
If there is no cogent reason for collecting a List and acting on it you should match a single Alarm and update it on the rule's right hand side: rule "Rule [Alarm Collection]" when $alarm: Alarm ( justInserted == true ) then modify( $alarm ){ setJustInserted( false ) } end Note that you still can store a reference to this Alarm in some global or call Java code for additional processing. If you do need a collected List, you'll have to copy it on the rule's right hand side before you call your Java code. ArrayList copy = new ArrayList( $alarmColl ); The update() call is causing instant reorganisation and the collect result is some sort of cache. On 12 April 2014 05:56, mohanm wrote: > Hi, > > I am using Drools 5.5.0 Final Expert to do Alarm Co-relation. I was trying > to collect the facts in to the ArrayList collection. My drl file will look > like below. From the Rule I calling an Java method to access the collected > facts. > > /rule "Rule [Alarm Collection]" > no-loop >when > $alarmColl : ArrayList() from collect(Alarm > ( > JustInserted == true; > )) > > then > // act on $alarmColl > end/ > > while in my Java code I am loop through the collection to set an attribute > of the Alarm Object. But while I am trying to set this attribute in the > collection, the collection is getting updated and indexes are changed. Due > to which all the objects are not updated. Even I tried using the iterator > to > access the ArrayList collection. Still the same issue. > > / > while(index < alarmColl.size()){ > Alarm alarmObj=alarmColl.get(index) > > if(alarmObj.isJustInserted()) { > alarmObj.setJustInserted(false); > theScenario.getSession().update(alarmObj); > } > index++; > }/ > > > How can I update the objects in collection without changing the index or > any > other way to achieve this. > > > > > -- > View this message in context: > http://drools.46999.n3.nabble.com/Problem-with-Collection-tp4029219.html > Sent from the Drools: User forum mailing list archive at Nabble.com. > ___ > 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
[rules-users] Problem with Collection
Hi, I am using Drools 5.5.0 Final Expert to do Alarm Co-relation. I was trying to collect the facts in to the ArrayList collection. My drl file will look like below. From the Rule I calling an Java method to access the collected facts. /rule "Rule [Alarm Collection]" no-loop when $alarmColl : ArrayList() from collect(Alarm ( JustInserted == true; )) then // act on $alarmColl end/ while in my Java code I am loop through the collection to set an attribute of the Alarm Object. But while I am trying to set this attribute in the collection, the collection is getting updated and indexes are changed. Due to which all the objects are not updated. Even I tried using the iterator to access the ArrayList collection. Still the same issue. / while(index < alarmColl.size()){ Alarm alarmObj=alarmColl.get(index) if(alarmObj.isJustInserted()) { alarmObj.setJustInserted(false); theScenario.getSession().update(alarmObj); } index++; }/ How can I update the objects in collection without changing the index or any other way to achieve this. -- View this message in context: http://drools.46999.n3.nabble.com/Problem-with-Collection-tp4029219.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users