"Exists" CE behaviour
by Chivotario Martin
Hi ,
I'm trying to use the *Exists *keyword within my rules with the following
snippet :
// Create a session
KnowledgeBaseConfiguration config =
KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
((RuleBaseConfiguration)config).setRuleBaseUpdateHandler( null ); *
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(config);
StatefulKnowledgeSession session = kbase.newStatefulKnowledgeSession();
// Add some objects
for (int i=0; i<5; i++) {
session.insert(new Foo());
}
// Add a DRL to the kbase
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add( ResourceFactory.newClassPathResource( "test/existsTest.drl" ),
ResourceType.DRL);
kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
// Fire rules
int fireCount = session.fireAllRules();
*existsTest.drl* :
rule "existsTest"
when
exists (Foo());
//not ( not ( Foo() ) ); (2)
then
System.out.println("Rule fired...");
end
When launched , the rule is not fired (no messages , fireCount 0), but it is
when changing
exists with a double not condition (2).
If the working memory is populated after adding the rules file, the exists
CE works as expected.
* I've used no RuleBaseUpdateHandler preventing automatic activations to be
executed so fireAllRules can be used to get the fireCount, but commenting
this line out doesn't change the results.
Probably i'm doing something wrong so a little help would be very
appreciated.
Regards,
Manuel.
16 years, 8 months
Unable to load dialect 'org.drools.rule.builder.dialect.java.JavaDialectConfiguration:
by Pardeep.Ruhil@lntinfotech.com
Hi,
I have set all the jars file in the classpath, but still m getting the
same exception.
The exception is caused by : Null pointer exception.
I am not able to understand why it is giving me this exception, while in
the mailing list I didn't found anybody having this
exception, everyone else I found has 'Class Not found Exception'.
This is my code snippet :
KnowledgeBuilderConfiguration config = KnowledgeBuilderFactory.
newKnowledgeBuilderConfiguration();
config.setProperty("drools.dialect.java.compiler", "ECLIPSE");
KnowledgeBuilder kbuilder =KnowledgeBuilderFactory.newKnowledgeBuilder(
config );
//KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource(
"shopingdiscount.drl"), ResourceType.DRL);
This is my exception:
Drools config: unable to use the drools.compiler property. Using default.
It was set to:0
org.drools.RuntimeDroolsException: Unable to load dialect
'org.drools.rule.builder.dialect.java.JavaDialectConfiguration:jav
:org.drools.rule.builder.dialect.java.JavaDialectConfiguration'
at
org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBuilderConfiguration.java:274)
at
org.drools.compiler.PackageBuilderConfiguration.buildDialectConfigurationMap(PackageBuilderConfiguration.java:259
at
org.drools.compiler.PackageBuilderConfiguration.init(PackageBuilderConfiguration.java:176)
at
org.drools.compiler.PackageBuilderConfiguration.<init>(PackageBuilderConfiguration.java:153)
at
org.drools.builder.impl.KnowledgeBuilderProviderImpl.newKnowledgeBuilderConfiguration(KnowledgeBuilderProviderImp
.java:17)
at
org.drools.builder.KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(KnowledgeBuilderFactory.java:57)
a
.
.
.
.
Caused by: java.lang.NullPointerException
at
org.drools.rule.builder.dialect.java.JavaDialectConfiguration.setCompiler(JavaDialectConfiguration.java:92)
at
org.drools.rule.builder.dialect.java.JavaDialectConfiguration.init(JavaDialectConfiguration.java:55)
at
org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBuilderConfiguration.java:270)
... 69 more
Am I missing anything that is to initialized , so that I can get through
this Null Pointer Exception.
Please help me to through of this situation. I am stuck in this.
Thanks & Regards
Pardeep Ruhil
______________________________________________________________________
16 years, 8 months
Sub flow : event : query
by Vikram Pancholi
Hi,
I am using version 5.1.0 Snapshot for compiler , api and core. My
requirement is as follows
1) Process A -- Main process --loops continuousy though a series of actions
/ splits and joins ...
there is a split constraint written which uses the level (mentioned
below).
2) Process B -- Sub process is as follows
1)Start
2)within process b, i m creating a timer task and sceduling it at say 1000
to insert a fact named Etrigger.
3)Event wait ;;-- waits for Etrigger
4)Increase the value of variable ..say level from 0 -> 1.
5)End the subprocess
But as soon as i insert the fact Etrigger looping of process A hungs up.
I tried using other options as well namely using fusion to insert the
Etrigger, but it doesnt expire even after giving expiry of 1 ms . And i
cannot confgure timer delay using a variable.
Thanks and Regards
*Vikram Pancholi*
16 years, 8 months
guvnor web based decision table
by Johan Kumps
Hi all,
I've a number of Excel based decision tables running in my applications. Now
I want to use Guvner to manage these rules. Only importing the xsl files is
not enough. So I have to manually convert the xsl's to a web based decision
table.
I have following questions :
- How do have have to use an eval condition? Whitin the eval I have to call
a piece of java code with a number of parameters coming from the fact model.
- How can I prioritize rules?
- How to use global variables?
Thanks for helping me out.
Kind regards,
Johan Kumps
16 years, 8 months
Failing serialisation of large rule base
by LadyCode
Hi,
I have written a Java application that reads in approximately 6000 .dslr
rules at runtime. This takes around 6minutes, however I have installed the
application on the target (rather old!) machine and load time is in excess
of 20minutes. I have been trying without success to find a way to speed up
loading:
I have tried:
1. Serialising the KnowledgePackages themselves. This works well but has
limited effect on load time.
2. Serialising the KnowledgeBase, this does not seem to work on large rule
bases and fails with StackOverflowException when I load more than about 200
rules.
3. Serialising the StatefulKnowledgeSession using
Marshaller marshaller = MarshallerFactory.newMarshaller(knowledgeBase);
marshaller.marshall(out, session);
This works well for the life of the marshaller but does not solve my problem
as I need to restart the application and therefore cannot use the same
instance of marshaller later on. Marshaller is not serialisable.
I know some of these points are discussed in other posts. But is there
anything I can do or have I missed the point?
Any help or comments very much appreciated,
Regards,
Jen
--
View this message in context: http://www.nabble.com/Failing-serialisation-of-large-rule-base-tp24444231...
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 8 months
RE: [rules-users] How to serialize a KnowledgeBase?
by LadyCode
Hi,
1) Your line 4 is fine you just need to do:
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
afterwards to 'associate' your packages with the knowledge base.
2) The KnowledgeBuilder is not serialisable though so I guess serialising
the KnowledgeBase IS the way to go. You can use DroolsObjectOutputStream to
serialise but it does not seem to work with large rule bases which defeats
the purpose in my case! Very annoying this serialisation business. I hope
you get it working.
Hamu, Dave wrote:
>
> I'm not up to snuff on Drools 5.0 M4, however, there are two
> observations that I have in regard to your question:
>
> 1) Given the code that you provided, line 4 is wrong. You cannot use a
> static KnowledgeBaseFactory to instantiate a KnowledgeBase without
> associating the KnowledgeBuilder instance. This is where my knowledge
> of the APIs is not clear, but you will need to execute some additional
> logic to move the knowledge-base rules from the KnowledgeBuilder to the
> KnowledgeBase.
>
> 2) It's not clear what optimization that you are hoping to achieve by
> serializing the Knowledge Base. Does it take a really long time to load
> the drl? Also, have you looked at serializing the kbuilder? I don't
> know if it's possible for certain, but that would be the next place that
> I'd look.
>
> Dave Hamu
> Systems Analyst
> AVNET, Inc.
> 8700 S. Price Rd.
> Tempe, AZ 85284-2608
> (480) 794-7909
> dave.hamu(a)avnet.com
>
>
> -----Original Message-----
> From: David Boaz [mailto:davidb@dbmotion.com]
> Sent: Wednesday, December 31, 2008 7:07 AM
> To: rules-users(a)lists.jboss.org
> Subject: [rules-users] How to serialize a KnowledgeBase?
>
>
> Hi all,
>
> Im currently developing a new application using drools 5.0 M4. Im using
> this style (from KnowledgeBuilder javadoc):
>
> 1- KnowledgeBuilder kbuilder =
> KnowledgeBuilderFactory.newKnowledgeBuilder();
> 2- kbuilder.add( ResourceFactory.newUrlResource( "file://myrules.drl" ),
> ResourceType.DRL);
> 3- assertFalse( kbuilder.hasErrors() );
> 4- KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
>
> Now, for optimization reasons, I want to save kbase. The problem is that
> it is not serializable.
> Probably, Im trying to serialize the wrong object.
>
> can someone please guide me how to do that?
>
> BTW, I have another question, How the KBFactory on line 4 knows the
> builder used in lines 1 and 2? Will it actually work?
>
> Thanks, David
> --
> View this message in context:
> http://www.nabble.com/How-to-serialize-a-KnowledgeBase--tp21231939p21231
> 939.html
> Sent from the drools - user mailing list archive at Nabble.com.
>
>
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
--
View this message in context: http://www.nabble.com/How-to-serialize-a-KnowledgeBase--tp21231939p244440...
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 8 months
Using field values of an ENUM in the decision table
by Visu Nageswaran
Hello, I am posting a simpler version of the actual requirement:
Class Computer has a field 'memory' of the enum type 'Memory' which is
defined over integer values
- - - - - - - - - -
public enum Memory{
MEM1(512), MEM2(1024), MEM3(2048);
public int value;
Memory(int i){this.value = i;}
public int getValue(){return value;}
}
- - - - - - - - - -
There is a requirement to model a decision table between memory and price
I am looking for the field constraint on the memory field to match to the
values:
memory.???--> Price
512 --> 100
1024 --> 200
2048 --> 300
I tried memory.name, memory.name(), memory.value, memory.getValue(); Does
this have to be done using template expressions say something like memory ==
Memory.reverseLookupEnum($param)
Any help, pointers in this regard would be appreciated. thanks.
-Visu
--
View this message in context: http://www.nabble.com/Using-field-values-of-an-ENUM-in-the-decision-table...
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 8 months
Rule with temporal operators
by PriyaSha
global java.lang.String output
declare OMNewTicket
@role( event )
@timestamp (timeStampAttr)
@expires (10m)
end
# Find 'critical' events of 'Windows' which occured after 1minute but before
10 minutes
# of 'warning' events of 'Symantec' provided no 'Security' with severity
'normal' exist in between
rule "Sample Temporal"
no-loop true
when
$ticket : OMNewTicket($severity1 : severity == "warning",
appName == "Symantec",
$timeStampAttr1 : timeStampAttr)
$ticket1 : OMNewTicket(this after[1m, 10m] $ticket,
severity == "critical",
$appName1 : appName == "Windows",
$timeStampAttr2 : timeStampAttr)
not (OMNewTicket( timeStampAttr <= $timeStampAttr2,
timeStampAttr >= $timeStampAttr1,
appName == "Login_failure", severity == "normal"))
then
drools.getWorkingMemory().setGlobal( "output", "found");
end
For the input :
e6382090-a259-71dd-12b9-92dfda160000 14178 10/25/2008:5:59:AM
warning Symantec Application
956cb3a0-a22d-71dd-09d7-c0195b7b0000 14178 10/25/2008:6:00:AM
warning Login_failure Security
28bdb2e0-a25a-71dd-1bc3-c01959f40000 14178 10/25/2008:6:05:AM
critical Windows Application
956cb3a0-a22d-71dd-09d7-c0195b7b0000 14178 10/25/2008:10:04:AM
normal Login_failure Security
20f39930-a27d-71dd-0369-81f8b3ee0000 14178 10/25/2008:10:04:AM
warning Symantec Application
648d5010-a27c-71dd-1bc3-c01959f40000 14178 10/25/2008:10:05:AM
critical Windows Application
8bcb9bb0-a32f-71dd-10c5-c01959dc0000 14179 10/26/2008:7:23:AM
warning Login_failure Security
8882ee70-a331-71dd-1fbc-c0068f170000 14179 10/26/2008:7:37:AM
warning Symantec Application
I get the below output:
405000 405000 0 warning
Symantec Sat Oct 25 05:59:00
406000 406000 0 warning
Login_failure Sat Oct 25 06:00:00
407000 407000 0 critical
Windows Sat Oct 25 06:05:00 found
408000 408000 0 normal
Login_failure Sat Oct 25 10:04:00
409000 409000 0 warning
Symantec Sat Oct 25 10:04:00
410000 410000 0 critical
Windows Sat Oct 25 10:05:00
411000 411000 0 warning
Login_failure Sun Oct 26 07:23:00 found
412000 412000 0 warning
Symantec Sun Oct 26 07:37:00
I use pseudo clock and I set the time in the third column(example
10/25/2008:5:59:AM) of the input as the 'timeStampAttr' by converting it to
long.
I also adjust the clock accordingly.
My requirement is to get the those 'critical-windows' event which happens
after 1 to 10minutes of 'warning-Symantec' provided no
'normal-Login_Failure' between them.
Problem here is, I could not get convinced with the occurance of found in
row #7. Coz 'Login_failure' did not occur between 10minute interval of a
symantec and windows event. Also my intention is to identify the windows
event.
--
View this message in context: http://www.nabble.com/Rule-with-temporal-operators-tp24370198p24370198.html
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 8 months