Thanks Edson
I read about “from” CE and understand that it can call any external method. In the external method I can write the code to extract the data from database.
I googled and found this, where its using hibernate session and that way giving complete flexibility in writing rule on any data set. Do you think it’s a good idea?
global org.hibernate.Session hibernateSession;
rule "hibernate_from"
when
game:Game() from hibernateSession.createQuery("select games from Player p where p.age >= :age").setProperties( {"age" : 18 }).list()
then
System.out.println("The game "+game.getName() +"is owned by "+game.getPlayers());
end
-----Original Message-----
From: rules-users-bounces@lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Edson Tirelli
Sent: Monday, June 01, 2009 6:48 PM
To: Rules Users List
Subject: Re: [rules-users] rule using sliding window
Hi
The description you have bellow is ambiguous, so I can't give you a definitive answer. But it seems to be that you don't need sliding windows for that. Simple temporal operators will do.
> Secondly if the window is large and number of records coming in is high then could there be a memory issue?
Yes, Drools does not manages persistence by itself. So, if your design must support more data than it would fit in your running environment memory, you need to design a solution that comprises persistence.
> Also since every record is getting stored in database, can I not use the database directly instead of sliding window?
Yes, you can fetch data on demand from external sources, be it databases or anything else. Look at the "from" CE.
[]s
Edson
2009/6/1 Bhushan Bhangale <bhushan_bhangale@kaleconsultants.com>
I am using Drools 5. I am struggling to write rule for this logic -
If a stock price changes more than 10% within an hour then report the change.
I understand I have to use sliding window feature but unable to write the rule.
For example I got an update for IBM stock @ 12:30 for price 100 and then another update IBM stock @ 12:35 for price 111. Since the time difference is within an hour and the change is also greater than 10% I want to report this price change.
Stock class -
Public class Stock {
Private String stock;
Private double price;
Private Date time;
Private double priceChange;
Private Boolean highlight;
}
rule "Stock Price change more than 10% within an hour"
when
then
set the priceChange attribute of Stock object
set highlight to true
end
Secondly if the window is large and number of records coming in is high then could there be a memory issue?
Also since every record is getting stored in database, can I not use the database directly instead of sliding window?
Thanks
Mr. Bhangale Bhushan
Associate Manager
Kale Consultants Ltd.
bhushan_bhangale@kaleconsultants.com
tel: +91 (0)206 608 3777
http://www.kaleconsultants.com
Disclaimer: This email (including any attachments) is intended for the soleuse of the recipient/s and may contain material that is CONFIDENTIAL. Anyunauthorized disclosure / copying / distribution or forwarding of this messageor part is STRICTLY PROHIBITED. If you have erroneously received this message,please delete it immediately and notify the sender. No liability is assumed forany errors and/or omissions in the contents of this message. Information inthis message that does not relate to the official business of this Companyshall be understood as neither given nor endorsed by it. If verification isrequired please request a hard-copy version.To know more about Kale Consultants, visit www.kaleconsultants.com----------
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
--
Edson Tirelli
JBoss Drools Core Development
JBoss, a division of Red Hat @ www.jboss.comDisclaimer: This email (including any attachments) is intended for the sole use of the recipient/s and may contain material that is CONFIDENTIAL. Any unauthorized disclosure / copying / distribution or forwarding of this message or part is STRICTLY PROHIBITED. If you have erroneously received this message, please delete it immediately and notify the sender. No liability is assumed for any errors and/or omissions in the contents of this message. Information in this message that does not relate to the official business of this Company shall be understood as neither given nor endorsed by it. If verification is required please request a hard-copy version. To know more about Kale Consultants, visit www.kaleconsultants.com ----------
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users