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
15 years, 5 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.
15 years, 5 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.
15 years, 5 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.
15 years, 5 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.
15 years, 5 months
Detect rules changes at runtime using a push mechanism
by rviswanathan
Hi
I am trying to detect rule changes (that I edit using Guvnor) at runtime in
my java program.
I was able to use the resource scanner (as provided in the drools
documentation) to poll and get the changes.
I am also trying to see the possibility of using a push based approach,
instead of the polling. I see the classes for the ResourceChangeMonitor,
ResourceChangeNotifier and ResourceChangeListener, but I am not sure how I
should go about using these.
I tried to use the following method on the ResourceChangeNotifier by passing
in a listener implementation and the ChangeSet as the resource - but what do
I implement inside this method?
void subscribeResourceChangeListener(ResourceChangeListener listener,
Resource resource)
Is this approach correct?
Thanks
Ram
--
View this message in context: http://www.nabble.com/Detect-rules-changes-at-runtime-using-a-push-mechan...
Sent from the drools - user mailing list archive at Nabble.com.
15 years, 5 months
ClassCastException when using an accumulate function on a locally declared type
by bill simms
Hello,
Recently I've been working with Drools version 5.0.1 to set up an event
processor. While doing so I have come
across difficulties with the accumulate function, in that it will always
throw a ClassCastException
when inserting events that are declared within my drl file. To illustrate
this I've set up an example which is
shown below. I've search Google and the mailing list for several hours, but
the only way past this problem
appears to be that I will have to declare a class externally and make sure
it implements Serializable. Does
anyone has suggestions for another approach? Secondly, I would have assumed
that since Drools was
compiling these internally declared classes, that Serializable would have
been implemented automatically. So
is this a result of the generated class not implementing Serializable, or
have I missed something in my rules
file? Thanks.
The important part of my drl file is:
declare TestEvent
@role( event )
@expires(10s)
id : String
end
#This rule works fine when 'Accumulate Count' is commented out, and is used
to make
#sure that the event inserting has worked.
rule "Is It There"
when
TestEvent() from entry-point "test"
then
System.out.println("Found a TestEvent.");
end
#This rule throws a ClassCastException when a TestEvent is inserted.
rule "Accumulate Count"
when
$n : Number() from accumulate($t : TestEvent() from entry-point
"test", count($t))
then
System.out.println("Found " + $n + " events.");
end
The unit test does this:
FactType testEventType =
session.getKnowledgeBase().getFactType("com.drools.test", "TestEvent");
for(int i = 0; i < 10; i++){
Object testEvent = testEventType.newInstance();
testEventType.set(testEvent, "id", "id");
WorkingMemoryEntryPoint mainStream =
session.getWorkingMemoryEntryPoint("test");
mainStream.insert(event);
session.fireAllRules();
}
The exception I receive is:
org.drools.RuntimeDroolsException: java.lang.ClassCastException:
com.drools.test.TestEvent cannot be cast to java.io.Serializable
at org.drools.rule.Accumulate.accumulate(Accumulate.java:172)
at org.drools.reteoo.AccumulateNode.modifyTuple(AccumulateNode.java:424)
at
org.drools.reteoo.AccumulateNode.assertObject(AccumulateNode.java:284)
at
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:42)
at
org.drools.reteoo.PropagationQueuingNode$AssertAction.execute(PropagationQueuingNode.java:326)
at
org.drools.reteoo.PropagationQueuingNode.propagateActions(PropagationQueuingNode.java:221)
at
org.drools.reteoo.PropagationQueuingNode$PropagateAction.execute(PropagationQueuingNode.java:394)
at
org.drools.common.AbstractWorkingMemory.executeQueuedActions(AbstractWorkingMemory.java:1486)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:158)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:122)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:80)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:28)
at com.drools.test.MyUnitTest.testEvents(EvaluationTest.java:66)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at
org.springframework.test.context.junit4.SpringTestMethod.invoke(SpringTestMethod.java:160)
at
org.springframework.test.context.junit4.SpringMethodRoadie.runTestMethod(SpringMethodRoadie.java:233)
at
org.springframework.test.context.junit4.SpringMethodRoadie$RunBeforesThenTestThenAfters.run(SpringMethodRoadie.java:333)
at
org.springframework.test.context.junit4.SpringMethodRoadie.runWithRepetitions(SpringMethodRoadie.java:217)
at
org.springframework.test.context.junit4.SpringMethodRoadie.runTest(SpringMethodRoadie.java:197)
at
org.springframework.test.context.junit4.SpringMethodRoadie.run(SpringMethodRoadie.java:143)
at
org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invokeTestMethod(SpringJUnit4ClassRunner.java:160)
at
org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
at
org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
at
org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
at
org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
at
org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
at
org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:97)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.lang.ClassCastException: com.drools.test.TestEvent cannot be
cast to java.io.Serializable
at
org.drools.base.accumulators.JavaAccumulatorFunctionExecutor.accumulate(JavaAccumulatorFunctionExecutor.java:110)
at org.drools.rule.Accumulate.accumulate(Accumulate.java:164)
... 36 more
15 years, 5 months
Re: [rules-users] Hibernate Query delivers wrong values
by Greg Barton
Yes, Hibernate caches in several ways. Go here:
http://docs.jboss.org/hibernate/stable/core/reference/en/html_single/
Search for "cache". :)
Some caching you can disable. (The 2nd level session factory cache.)
http://docs.jboss.org/hibernate/stable/core/reference/en/html_single/#con...
The cache on the session cannot be disabled, but you shouldn't be using hibernate sessions for the long term anyway. (i.e. a new one should be opened up each time the rule condition is evaluated.)
--- On Fri, 7/10/09, Thomas Zwifl <tom238(a)gmx.at> wrote:
> From: Thomas Zwifl <tom238(a)gmx.at>
> Subject: [rules-users] Hibernate Query delivers wrong values
> To: rules-users(a)lists.jboss.org
> Date: Friday, July 10, 2009, 5:46 AM
> Hi there!
>
> I'm working with the latest snapshot-releas of v5.1
> (build3098-rev27324-20090630-0403).
> My application consists of two independent processes,
> both are repeated periodically (timer-node).
> the processes both have ruleset-nodes. some rules are
> querying a database with hibernate in the rule condition
> (LHS).
> the queried objects are then inserted into workinmemory
> (insert(object)),
> then some computation follows, the objects are modified and
> written
> back to db, and then the objects are retracted
> (retract(object)).
>
> Now to the problem: when I start the application,
> everything works
> correct, and leads to the right results. But when I change
> a field of a
> db-record manually, the hibernate-query delivers the old
> values!!
> (of course the changes are committed.)
>
> Anyone has an idea whats going wrong here? Is there some
> kind of
> caching mechanism that delivers the old objects instead of
> querying
> the database?
>
> greetz!
> tom
> --
> GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
> Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
15 years, 5 months