Building our own UI for Drools
by kapokfly
Due to some reasons (for example, build a consistent UI within our own
application, easier to work with our own meta data, don't want SSO etc), we
are considering to build our own UI to generate Drools rule file basing on
the user input via the UI , has anyone tried this before? Is there any
library shipped within Drools Gunvor can be used to be easier to work with
Drools rule syntax?
Thanks,
Ivan
-----
Ivan, your Panda, forever
--
View this message in context: http://drools.46999.n3.nabble.com/Building-our-own-UI-for-Drools-tp350884...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 7 months
Best practice to use heap memory effectively
by mohan
Hi ,
I want to keep events valid for 24 hour period. Per day I’m getting over
1000K events & insert into session. I saw that heap usage increase
drastically because of this. What is the best practice to handle such a
situation? Do I need to choose some caching mechanism?
Meantime I’m using “Statefulknowledge” session and use single session to
cater each event & never call session.dispose(). Will there be any impact?
I’m using Drool 5.1.1, jboss-5.1.0.GA, jre 1.6.0_33
Thanks.
Mohan
--
View this message in context: http://drools.46999.n3.nabble.com/Best-practice-to-use-heap-memory-effect...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 7 months
Re: [rules-users] JITting error with 5.5.0.CR1
by paulk_asert
I should have added that the script still completes successfully, it is only
the JIT optimization that is having problems and only when some threshold is
reached causing an attempt at performing the optimization - as per
descriptions I have read earlier. The problem is that I thought there was a
fix already in place for this problem if I read the earlier posts correctly
but perhaps I do not know how to enable it.
paulk_asert wrote
> When I run this Groovy script using drools 5.5.0.CR1 with numAnimals = 8
> and numLegs = 120, it works fine. If I set numAnimals = 17 and numLegs =
> 1020 then it fails with a JITting error. I saw a bunch of Jira issues
> related to JITting issues but no open ones seemed to match exactly.
>
> @GrabResolver('https://repository.jboss.org/nexus/content/groups/public-jboss/')
> @Grab('org.drools:knowledge-api:5.5.0.CR1')
> @Grab('org.drools:drools-compiler:5.5.0.CR1')
> @Grab('org.drools:drools-core:5.5.0.CR1')
> @Grab('com.sun.xml.bind:jaxb-xjc:2.2.5.jboss-1')
> @GrabExclude('com.github.relaxng:relaxngDatatype')
> @GrabResolver('http://repo2.maven.org/maven2/')
> @Grab('org.mvel#mvel2;2.1.2.Final')
> @Grab('org.slf4j#slf4j-simple;1.6.4')
> import groovy.transform.Immutable
> import static org.drools.KnowledgeBaseFactory.newKnowledgeBase
> import static
> org.drools.builder.KnowledgeBuilderFactory.newKnowledgeBuilder
> import static org.drools.builder.ResourceType.DRL
> import static org.drools.io.ResourceFactory.newReaderResource
>
> def numAnimals = 8
> def numLegs = 120
> def kbuilder = newKnowledgeBuilder()
> def drl = '''
> dialect "mvel"
> rule "deduce animal counts"
> when
> $crane : Crane( )
> $centipede : Centipede( )
> $tortoise : Tortoise(
> quantity + $crane.quantity + $centipede.quantity == ''' + numAnimals
> + ''',
> quantity * numLegs + $crane.quantity * $crane.numLegs +
> $centipede.quantity * $centipede.numLegs == ''' + numLegs + '''
> )
> then
> System.out.println( "Cranes " + $crane.getQuantity() )
> System.out.println( "Tortoises " + $tortoise.getQuantity() )
> System.out.println( "Centipedes " + $centipede.getQuantity() )
> end
> '''
> kbuilder.add(newReaderResource(new StringReader(drl)), DRL)
> def kbase = newKnowledgeBase()
> kbase.addKnowledgePackages(kbuilder.knowledgePackages)
> def ksession = kbase.newStatefulKnowledgeSession()
>
> (numAnimals + 1).times { n ->
> if (numLegs.intdiv(Crane.numLegs) >= n) {
> ksession.insert(new Crane(n))
> }
> if (numLegs.intdiv(Tortoise.numLegs) >= n) {
> ksession.insert(new Tortoise(n))
> }
> if (numLegs.intdiv(Centipede.numLegs) >= n) {
> ksession.insert(new Centipede(n))
> }
> }
>
> ksession.fireAllRules()
> ksession.dispose()
>
> @Immutable
> class Crane {
> static int numLegs = 2
> int quantity
> }
>
> @Immutable
> class Tortoise {
> static int numLegs = 4
> int quantity
> }
>
> @Immutable
> class Centipede {
> static int numLegs = 100
> int quantity
> }
>
> Here is the error message:
>
> Exception in thread "Thread-1" java.lang.RuntimeException: Exception
> jitting: quantity + $crane.quantity + $centipede.quantity == 17 &&
> quantity * numLegs + $crane.quantity * $crane.numLegs +
> $centipede.quantity * $centipede.numLegs == 1020
> at
> org.drools.rule.constraint.MvelConstraint.executeJitting(MvelConstraint.java:275)
> at
> org.drools.rule.constraint.MvelConstraint.access$200(MvelConstraint.java:51)
> at
> org.drools.rule.constraint.MvelConstraint$ConditionJitter.run(MvelConstraint.java:250)
> at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
> at java.lang.Thread.run(Thread.java:722)
> Caused by: java.lang.RuntimeException: java.lang.RuntimeException: Error
> writing method evaluate
> at
> org.drools.rule.builder.dialect.asm.ClassGenerator.newInstance(ClassGenerator.java:200)
> at
> org.drools.rule.constraint.ASMConditionEvaluatorJitter.jitEvaluator(ASMConditionEvaluatorJitter.java:53)
> at
> org.drools.rule.constraint.MvelConstraint.executeJitting(MvelConstraint.java:273)
> ... 5 more
> Caused by: java.lang.RuntimeException: Error writing method evaluate
> at
> org.drools.rule.builder.dialect.asm.ClassGenerator$MethodDescr.write(ClassGenerator.java:881)
> at
> org.drools.rule.builder.dialect.asm.ClassGenerator.generateBytecode(ClassGenerator.java:128)
> at
> org.drools.rule.builder.dialect.asm.ClassGenerator.generateClass(ClassGenerator.java:144)
> at
> org.drools.rule.builder.dialect.asm.ClassGenerator.newInstance(ClassGenerator.java:198)
> ... 7 more
> Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
> at org.mvel2.asm.Frame.merge(Frame.java:1373)
> at org.mvel2.asm.Frame.merge(Frame.java:1329)
> at org.mvel2.asm.MethodWriter.visitMaxs(MethodWriter.java:1282)
> at
> org.drools.rule.builder.dialect.asm.ClassGenerator$MethodDescr.write(ClassGenerator.java:879)
> ... 10 more
>
> Is this a known issue?
>
> Thanks, Paul.
--
View this message in context: http://drools.46999.n3.nabble.com/JITting-error-with-5-5-0-CR1-tp4020565p...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 7 months
Drools Guvnor API information?
by Vikas Hazrati
Hi,
I am looking at using Guvnor for our project where users would be creating
rules using our UI. For this i need to add / modify rule or any asset for
that matter using an api.
Unfortunately, i could not find enough documentation to suggest the best way
to use the REST api, which I guess is provided by Guvnor. Could someone let
me know the location of where i can get some information for this api. I
also see that the issue GUVNOR-1080
(https://issues.jboss.org/browse/GUVNOR-1080) is marked resolved so the api
should exist right? or that we cannot access it remotely until we have the
Atom Pub Interface done?
Help appreciated .
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Drools-Guvnor-API-inf...
Sent from the Drools - User mailing list archive at Nabble.com.
13 years, 7 months
How can I nested rules
by leonardo_josue
Hi everybody, I hope some of you can tell me if I can do something with my
problem.
I have a table in a DB with medical information from too many patients. This
information was captured in paper and after put into the table. The
questions have a sequence, and a few answers depend of other answers, for
example:
P1. Age:____
P2. Gander: 1: Female, 2: Male
--> if P1 >= 12 and P2 = 1 then go to p3, else go to p5
P3. How many times have you been pregnant? 0, 1, 2, 3, 4, 5, ______
--> if number > 1 go to P3 else P5
P4. How many babes were born alive? 0, 1, 2, 3, 4, 5, _______
P5. Do you smoke? 1: no, 2: yes
In the table I have something like this:
mysql> SELECT * FROM table;
|id||P1|P2|P3|P4|P5|STATUS
------------------------------
|1|34|1|3|2|1|NULL
|2|10|1|3|2|1|NULL
|3|21|2|1|1|1|NULL
|4|66|1|0|1|1|NULL
|5|14|2|NULL|NULL|1|NULL
|6|09|1|NULL|NULL|1|NULL
I try to set STATUS = "OK" when information was consistent, i.e.
ID = 2. A girl of 10 years hardly been pregnant 3 times
ID = 3. A man can't get pregnant or abort
ID = 4. A woman can't abort if the number of times she has become pregnant
is zero
I'll try to use Drools to do something like this.
rule "Age and gender women"
no-loop
when
p : Person(p1 >= 12 && p2 = 1)
then
//execute rule "Pregnant"
end
rule "Pregnant"
no-loop
when
p : Person(p3 > 1)
then
//execute rule "Aborts"
end
rule "Pregnant"
no-loop
when
p : Person(p4 <= P3)
then
//it's ok
p.Status = 'OK'
end
Is this possible??? I read than you can't nested rules, but I want to know
if exist some way to do. Since now my thanks for any help.
Best regards.
Leo.
--
View this message in context: http://drools.46999.n3.nabble.com/How-can-I-nested-rules-tp4020488.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 7 months
Calling queries or collect() from functions
by Miguel Paraz
Hi,
I have a rule like:
rule "Rule1"
when
$fact: Fact1()
$allFacts: ArrayList() from collect(Fact1())
then
insert(new Fact2($allFacts.size()));
end
I want to compute $allFacts inside a function since I will use it across
different rules.
This doesn't work because it is not valid Java syntax:
function int size() {
ArrayList a = ArrayList() from collect(InQueuePredicate());
return a.size();
}
Could I put this in a named query, and call it from a function?
Thanks!
Miguel
13 years, 7 months
Re: [rules-users] Eclipse Debugging Drl file
by benq2188
Hello,
I faced with the same problem. Breakpoints are not being hit by debugger. I
have Eclipse SDK version: 4.2.1 and went through the reference manual of
Drools and followed each step carefully.
-Installed GEF
- Downloaded drools-distribution-5.4.0.Final.zip
-Unzipped it into Eclipse main folder
-Restarted Eclipse
-Defined run time based on the latest Drools project jars included in the
plugin
itself.
-Created Drools Project
-Created new launch configuration for Drools Application.
-Put a breakpoint in the helloworld simple project on the first line of the
section "then".
When I debug it as Drools Application, debugger stops in Java breakpoints
but doesn't stop in drl rule.
Any solutions, how can I fix it?
Thanks in advance.
--
View this message in context: http://drools.46999.n3.nabble.com/Eclipse-Debugging-Drl-file-tp3870257p40...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 7 months
Drools 5.5.0.CR1 is using a broken cdi-api version
by Cristiano Gavião
Hello,
I'm using Tycho to create a dependency P2 repository (OSGi environment)
containing JBPM 5.4.0.CR1 and DROOLS 5.5.0.CR1.
I got some problem to properly setup the dependencies for the cdi-api.
The bundle knowledge-internal-api has a dependency to cdi-api (version
1.0-SP4), but this version is tied to this:
<groupId>org.jboss.spec.javax.interceptor</groupId>
<artifactId>jboss-interceptors-api_1.1_spec</artifactId>
<version>1.0.0.Beta1</version>
And this 1.0.0.Beta1 version of org.jboss.spec.javax.interceptor was not
well osgified. it doesn't have a Bundle-SymbolicName !
I could handle this problem using a newer version of it:
<dependency>
<groupId>org.jboss.spec.javax.interceptor</groupId>
<artifactId>jboss-interceptors-api_1.1_spec</artifactId>
<version>1.0.1.Final</version>
</dependency>
I won't use cdi anyway, but it could help others that decide to use jbpm
with eclipse.
regards,
Cristiano
13 years, 7 months