Can Drools be Used for this application?
by cyphr
Hi,
I have a scenario where i have:
- A listener that listens to a port and collects datapackets(Logs of
Events) as they come and dumps to a DB.
- consider the data that goes into my table is parsed, processed
(meaningful, not raw anymore).
Can Drools sit in between this listener and my DataBase to achieve the
following :
1. Monitor the frequency of occurrence? Say if/when event 'X' occurs 'n'
times in a 'z' time window?
2. ignore event 'X' until it occurs n times.
3. track a sequence of events - event X followed by event y within a fixed
time window.
(the RHS for any of these is, at the moment, not very consequential. i might
just raise a flag or something to indicate something has happened...)
My query is primarily to understand if this can be achieved.
i may have around a million logs a day, but - only one event at a time is
passed from the listener to Drools. Can drools hold the knowledge of
previous facts(like count) into its working session? or does it require to
store all these facts also?
Should i be firing the rules whenever each log/event enters my system? or
should i accumulate the day's facts ? (but i might have rules that need to
catch conditions spreading over a few days ...)
Some pointers or suggestions on this would be great!
Thanks!
--
View this message in context: http://www.nabble.com/Can-Drools-be-Used-for-this-application--tp23170278...
Sent from the drools - user mailing list archive at Nabble.com.
15 years, 6 months
Re: [rules-users] Hibernate proxy objects equality tests failing in Drools 5
by Guto
I was following that subject on markmail, and them I've enterred the
user-group (so subject and body are coppied from them). I've got the
exactly same problem. When I use the rules with objects the came from the
database (thru JPA hibernate provider), thouse rules never match. When I
do the same from Pojos hand made for unit test, it work.
I don't know what really happen, but i'm sure that it is an equality test
falling 'cause of the hibernate proxys.
I don't get also any kind of error or exception, since it ALL WORK. Just
the rule isn't be acomplished.
I'm using EJB3 + JPA (hibernate provider) and Drools 4 GA;
thanks in advance for any help
--
Guto Maia
CSM - SCJP- SCWCD - SCBCD - ZCE
Chris,
When you use "==" in a DRL field constraint (not eval), drools always
translates it into an .equals() call.
Having said that, there might be other problems, since drools must rely on
object identity for some internal data structures... for instance, we use
IdentityMaps for mapping FactHandles and the actual fact objects, etc.
We would need to test this and see what can be done. Could you please open
a JIRA and attach a test case so that we can reproduce the problem?
Thanks, Edson
2009/4/26 CK <chri...(a)gmail.com>
Hi,
I'm testing out some simple codes using Hibernate and Drools 5 and I'm
hitting an issue with hibernate proxy objects.
With the newer version of hibernate, Javassist is used to proxy some
hibernate objects. By doing this, hibernate objects essentially cannot use
== comparisons, which is fine.
However, this is causing issue in equality checks within Drools 5 LHS
evaluations of hibernate persistent objects.
Let's say for example I have the following Hibernate objects:
class Parent { Child child; }
class Child { String name; }
normally, if you output Parent.child, it should be Child.class. But under
Hibernate, the child property in Parent may be proxied and enhanced with
Javassist, thus making Parent.child.class to be something like
"Child_$$_javassist_75".
Inside Drools, in the LHS:
when $child : Child() $parent : Parent(child == $child) then ... end
Assume that I have insert separate Child instances here that were
retrieved from an Hibernate query directly. Assume that I have also
inserted Parent instances that were retrieved from a separate query
without eager fetching. Given this particular case, the above rule would
not match even though it technically should. Under normal java code, using
equality, the parent's child is equal to the child.
According to MVEL language, which Drools LHS may not necessarily be using,
equality between two objects are compared using values. Not sure exactly
what that means.
Either way, this seems to be a rather unfortunate problem for using Drools
to work with Hibernate objects. Older hibernate versions didn't cause this
problem.
It seemed like jBPM had a similar problem according to the following doc:
http://www.jboss.org/community/docs/DOC-11169
Excerpt:
Object identity and object equality
MAKE SURE TO USE ALWAYS .equals AND NEVER == comparisons in the Java code.
Typically, in the PVM Java objects, we want to use the default object
identity as the object equality. But hibernate persistence breaks this
(even within the scope of one hibernate session) because of the proxies.
So we have to apply a trick in order to make the comparison between a
persistent object and its proxy return true. See jBPM 3 class EqualsUtil
for that trick.
So my question is whether Drools uses equality or identity when it comes
to comparing values in LHS constraints. Is there a way to get around this
issue?
-Chris
_______________________________________________ rules-users mailing list
rule...(a)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.com
_______________________________________________ rules-users mailing list
rule...(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
15 years, 6 months
ascendant compatibility drools 4.0 <-> drools 2.0 ?
by Gab Aldien
Hi everybody
Short presentation since this is my first time posting there. I am a french
engineering student at the end of his studies, and I am currently working as
a trainee on a project where I have to make a lot of software working
together. I am currently studying a way to correlate alarms sent by a lot of
equipements from a network (type NMS), using openOSS' correlation module,
which was using drools 2.0 beta 2.1
But since it seems the current stable version is drools 4.0, I am thinkint
about using it instead. But if I do so, I will have to bother about
ascendant compability. The programm from openOSS is using drools through
JSR94 interface. Do you think there will be any problem? Where can I find a
good page relating major changes in drools since drools 2.0?
Other question: my project is really ambitious, and I plan to use rules
which will adapt to the topology of the network. Depending on what is
possible in drools, I am thinking about creating a program which will use a
file containing static rules and another one containing the topology of the
network to remotely generate new rules each time I change the network
topology. But maybe this dynamic rule generation is already available in
drools? What do you think?
Thank you very much
Aldian
15 years, 6 months
How to get workItem name?
by brian.xiang@thomsonreuters.com
Hi,
For example if I have a workItem defined like this:
<nodes>
<workItem id="2" name="Bob" x="63" y="136" width="117" height="40" >
<work name="Email" >
<parameter name="inputType" >
</parameter>
</work>
<mapping type="in" from="content" to="content" />
</workItem>
</nodes>
How do I get the work item name - Bob? WorkItem.getName() returns
"Email" which is to me kind of the type of the WorkItem, not the name of
the WorkItem instance.
Thanks in advance,
Brian
15 years, 6 months
Locating facts via slot values
by Wolfgang Laun
Given a working memory containing a large number of rather static facts
which are from several subclasses (Ape, Bear, Crocodile,...) of some base
class (Animal) and a single fact of class Hunter with a field target of type
Animal, the shooting of an animal might be written with a rule like this:
rule shoot-1
when
?h : Hunter( ?target : target )
?a : Animal()
eval(?target == ?a)
then
?h.shoot( ?a );
retract( ?a );
end
Avoiding eval (which is said to be inefficient), it could also be written as
rule shoot-2
when
?a: Animal()
?h : Hunter( target == ?a )
then
?h.shoot( ?a );
retract( ?a );
end
This, however, places the pattern with many instances up front, which is
(AFAIK) not so good in a Rete implementation.
Which one is to be preferred in Drools?
Ideally, one might want to write
rule shoot-3
when
?h : Hunter( ?target : target )
?a == ?target : Animal() ### not valid DRL
then
?h.shoot( ?a );
retract( ?a );
end
This avoids eval, has the single instance fact up front, but it isn't
available.
-W
15 years, 7 months
CEP functionality
by David Boaz
Dear all,
We posted this question two weeks ago, but with no replies. please forgive
me for posting it again.
In our business, most of the facts have time-stamp attributes. For example,
each laboratory test (a fact) has the time stamp when the sample was taken,
and when the machine produced the result value. In our business-logic, we
often analyze the relation between facts using these attributes.
For example:
1) finding two adjacent labResults with an increasing value
2) checking whether 3 facts are consecutive
3) counting the number of facts fulfilling a specific constraint within a
specific time window.
We were happy to read (in the blog) about the new CEP feature which is about
to be added to drools 5.0.
* Where can we find a more detailed description of CEP functionality in
drools?
* Is it a good idea to use CEP for analyzing historic data (retrieved from
the database)? or is it best for online data.
* Can we use CEP in a stateless session?
* As we understand, CEP attaches to each fact a temporal attribute of the
assertion time. Can we define that a particular attribute (e.g.,
LabResult.samplingDate) will be used as the time stamp? Or, should we assert
the facts by their temporal order, and advance the session-clock
appropriately?
* Can we use CEP to analyze the data in the examples above?
Many thanks for the help, David
--
View this message in context: http://www.nabble.com/CEP-functionality-tp19020709p19020709.html
Sent from the drools - user mailing list archive at Nabble.com.
15 years, 7 months
Stateless session and rule flows
by Yoni Mazar
Hi Guys,
We are trying to work with drools with stateless session (Sequential) and to
apply rule flows.
we use the following code:
//define diagnosis and patient here
...
StatelessSession session = ruleBase.newStatelessSession();
//Here we would like to use: session.startProcess("ruleflow id") but this is
a method which belongs to
//StatefullSession only.
session.execute(new Object[] {diagnosis, patient});
How can we do that in steteless mode?
Thanks,
Yoni
--
View this message in context: http://www.nabble.com/Stateless-session-and-rule-flows-tp17863849p1786384...
Sent from the drools - user mailing list archive at Nabble.com.
15 years, 7 months