Group-by rule without using a fact for grouping purposes
by IK81
Hi,
I am trying to figure out a rule for matching an incoming sequence of
events, but so far I was not really successful. Basically, I want to
process events from devices. Every event has a timestamp (long), an id
(a UUID string), a deviceId and an error code (both are strings).
What I want to have is a simple rule that fires, if a single device
reports a certain error code (e.g. ABCD) 3 times within 5 minutes (i.e.,
getting 3 such events within 5 minutes). So far, I suceeded in counting
the ABCD error codes in the time window as follows:
rule "Detect 3 occurrences of code ABCD for a certain device"
when
Number( intValue == 3 ) from accumulate(
Event( $i : id, code == "ABCD") over window:time( 5m ),
count( $i ) )
then
System.out.println("Raise alarm");
end
This first attempt does not distinguish which device sent the error
code. But how can I express to fire only if the events share the same
deviceId? I found many solutions that use a fact (e.g., a device fact)
to group by the device and do the accumulation. I successfully
implemented the group-by using the following when-part of the rule.
when
Device($deviceId : id)
Number( intValue == 2 ) from accumulate(
Event( $i : id, deviceId == $deviceId, code == "ABCD") over
window:time( 5m ),
count( $i ) )
then
Adding a device fact is however not practical in my case. Are there any
alternatives for expressing this group-by?
Thanks,
Ingo
10 years, 11 months
Http 401 error in drools 5.6.0.CR1
by nkhogen
If a change set has a resource pointing to Guvnor in 5.6.0.CR1, the resource
is rejected because of http 401 because basicAuthentication is enabled by
default.
Previously in 5.5.0.Final, in addResourceMapping(Resource resource, boolean
notify), there was no check for existence of the resource as
if ( notify && newMapping ) { ... }
In 5.6.0.CR1, it has been changed to
if ( notify && newMapping && ((InternalResource)resource).exists() ) { ..}
and the the exists() method simply invokes URL.openStream() which fails with
401 (unauthorized) and the resource is not added.
--
View this message in context: http://drools.46999.n3.nabble.com/Http-401-error-in-drools-5-6-0-CR1-tp40...
Sent from the Drools: User forum mailing list archive at Nabble.com.
10 years, 11 months
What Class is the Fact that was inserted? - How to dump working memory?
by Ray Hooker
I am trying to determine precisely what class the rules engine (kie version
6) thinks the class is that was inserted. The situation is that I am
inserting objects from JRuby.
1. If I pass the object to a Java program and do reflection, the class is
shown to be RubyObject (i.e., "getClass().getName".
2. I did create a rule that fires on any RubyObject that is inserted but
it never fires:
import org.jruby.RubyObject;
rule "Find any RubyObject"
dialect "mvel"
when
RubyObject()
then
System.out.println("We found a RubyObject!");
end
3. When I insert an object from JRuby that is called "Message", there is
what I see:
[ObjectInsertedEventImpl: getFactHandle()=[fact
0:1:529888082:529888082:1:DEFAULT:NON_TRAIT:#<Message:0x1f957352>],
getObject()=#<Message:0x1f957352>,
getKnowledgeRuntime()=org.drools.core.impl.StatefulKnowledgeSessionImpl@5719510f,
getPropagationContext()=PhreakPropagationContext
[entryPoint=EntryPoint::DEFAULT, factHandle=[fact
0:1:529888082:529888082:1:DEFAULT:NON_TRAIT:#<Message:0x1f957352>],
leftTuple=null, originOffset=-1, propagationNumber=2, rule=null, type=0]]
How can find out exactly what are the facts in working memory and determine
the precise nature of the fact I inserted?
Ray Hooker
--
View this message in context: http://drools.46999.n3.nabble.com/What-Class-is-the-Fact-that-was-inserte...
Sent from the Drools: User forum mailing list archive at Nabble.com.
10 years, 11 months
Drools hangs when running decision table
by Arshdeep Mand
I have the following code:
function runDecisionTable() {
...Other setup code...
val ksession = kbase.newStatelessKnowledgeSession()
println("About to execute")
ksession.execute(params)
println("Done executing")
}
This function will execute just fine exactly 10 times. However, when the
function executes for the 11th time, all I see is the message "About to
execute" and the java process seems to hang at the "kession.execute" line.
Anyone have any clue on how to debug this?
I tried to add some logging by doing:
val logger = KnowledgeRuntimeLoggerFactory.newConsoleLogger(ksession);
However, I get the following error when doing this:
java.lang.RuntimeException: Provider
org.drools.core.audit.KnowledgeRuntimeLoggerProviderImpl could not be set.
10 years, 11 months
Guided Rule Template globals
by marjan.sterjev
Hi,
I’m trying to implement Guided Rule Template in KIE WB (Guvnor).
The logic is simple: The Condition shall check range of ages and for action
call a method on a global.
The global is defined in Global Variables artifact.
I can see two problems with the editor:
1. I can choose the global variable (Call method on ‘global variable’).
However the global is not defined in the Source Code (for example: global
MessageCollection $messages).
2. The editor for Call method on ‘global variable’ allows to choose only
literal arguments. How about Template Keys? It seems natural to define
Template Keys for conditions and action callbacks as well.
Because of 1) when executing the rules, I have Null Pointer Exception.
In short what should I do in order to insert the global variable declaration
on the top of rules file (in the Guided Rule Template)?
--
View this message in context: http://drools.46999.n3.nabble.com/Guided-Rule-Template-globals-tp4027096....
Sent from the Drools: User forum mailing list archive at Nabble.com.
10 years, 11 months
drools-camel-server source code? (Drools 6)
by Jordan Brown
Hi,
I found the WAR file (or at least one called drools-camel-server-example-6.0.0.Final.war which has example, so I am not completely sure that's it), but I was hoping to get my hands on the source code behind the Drools Camel Server. We would like to incorporate the rules created in Drools 6 Guvnor/Workbench into the knowledge base of the drools camel server. I know <drools:resource... doesn't exist anymore to source say a "Change Set", which we do for Guvnor on Drools 5.x. It looks like I would have to use a remote maven repository that's created in Drools 6 Workbench and connect it in the drools camel server.
For more background, our current environment is sending messages through Glassfish JMS queue and a custom interface to translate those messages into which Drools 5.x understands. Now, we're R&D using RabbitMQ, drools camel server, and Drools 6 Workbench for a more enterprise/scalable solution, especially concerning the message system (want to get away from Glassfish and use RabbitMQ). At this point, we've created a test rule in Drools 6 Workbench, but we want to try and fire that rule using drools camel server.
I see in the documentation information concerning the Apache Camel Integration, but it's only the WAR file (with a specific test rule/DRL already in place that is being fired). I would like to take a look at the source code, but I don't see where it's available.
Best Regards,
Jordan Brown
[Description: Rackspace_EBI_logo_horiz_white]
View our EBI Team Wiki at: https://one.rackspace.com/display/EBI/Enterprise+Business+Intelligence+Home
Need something from EBI? Email us at: RackerBl_Team(a)rackspace.com<mailto:DL_RackerBl_Team@rackspace.com>
Phone: (x)501-5371, (c)210-289-1702
10 years, 12 months
JRuby Objects as Drools Facts
by Ray Hooker
I have seen where one group in India claimed to be able to inserts JRuby
objects as facts to Drools. I am very open to suggestions. The JRuby
objects appear to Java to be class RubyObject. When I insert say a JRuby
class named "Message", here is the message:
[ObjectInsertedEventImpl: getFactHandle()=[fact
0:1:341074620:341074620:1:DEFAULT:NON_TRAIT:#<Message:0x145462bc>],
getObject()=#<Message:0x145462bc>,
getKnowledgeRuntime()=org.drools.core.impl.StatefulKnowledgeSessionImpl@4cb91eff,
getPropagationContext()=PhreakPropagationContext
[entryPoint=EntryPoint::DEFAULT, factHandle=[fact
0:1:341074620:341074620:1:DEFAULT:NON_TRAIT:#<Message:0x145462bc>],
leftTuple=null, originOffset=-1, propagationNumber=2, rule=null, type=0]]
On the other hand if I insert a Java class in the same way, it is seen as:
==>[ObjectInsertedEventImpl: getFactHandle()=[fact
0:1:1319007734:1319007734:1:DEFAULT:NON_TRAIT:com.antelopesoftware.drools.Message@4e9e75f6],
getObject()=com.antelopesoftware.drools.Message@4e9e75f6,
getKnowledgeRuntime()=org.drools.core.impl.StatefulKnowledgeSessionImpl@139ba1d8,
getPropagationContext()=PhreakPropagationContext
[entryPoint=EntryPoint::DEFAULT, factHandle=[fact
0:1:1319007734:1319007734:1:DEFAULT:NON_TRAIT:com.antelopesoftware.drools.Message@4e9e75f6],
leftTuple=null, originOffset=-1, propagationNumber=2, rule=null, type=0]]
So how can I get the Drools engine to recognize the fact. BTW my real
application is read from a MongoDB database using Mongoid and insert the
data into Drools. I wrote wrapper Java classes to make it easier.
Thanks in advance,
Ray
--
View this message in context: http://drools.46999.n3.nabble.com/JRuby-Objects-as-Drools-Facts-tp4027079...
Sent from the Drools: User forum mailing list archive at Nabble.com.
10 years, 12 months
drools 6 equivalent of addKnowledgePackages
by pmander
Just doing some investigation of the drools 6 release. We dynamically build
our rules and use some thing like the following to bring them into a
stateful session:
KnowledgeBuilder builder = KnowledgeBuilderFactory.newKnowledgeBuilder();
builder.add(ResourceFactory.newReaderResource(new StringReader(
compiledRules)), ResourceType.DRL);
KnowledgeBuilderErrors errors = builder.getErrors();
kbase.addKnowledgePackages(builder.getKnowledgePackages());
This appears to be deprecated but there is no indication in the javadoc for
what the alternative is.
--
View this message in context: http://drools.46999.n3.nabble.com/drools-6-equivalent-of-addKnowledgePack...
Sent from the Drools: User forum mailing list archive at Nabble.com.
10 years, 12 months