OSGI, classloading, and imports in KnowledgeBuilder
by msully
So I'm playing with Drools in Equinox OSGi, and so far it's behaving quite
nicely - one bit of weirdness though.
What I'm trying to do:
I have a bundle with a 'flow manager' that listens for instances of
WorkItemHandler in the service broker (well, really my own subinterface that
has a getName method). It also listens for new bundles with a
META-INF/drools directory with *.rf files in them, and parses the .rf files
it finds there.
The Flow Manager is itself published as an OSGI Service with a 'perform'
method. It encapsulates all of its Drools calls within the perform method
though - they aren't exposed to clients.
My test involves a simple start->work item->end workflow.
I pass in an instance of a class "Tablex" that can be saved to hibernate. I
also pass in a String that has the table name, and an empty List to get the
results.
My .rf file tries to import Tablex. It declares the three values I mention
above, and maps them to the work item in the work item definition.
<p>
<imports>
<import name="my.pkg.Tablex" />
</imports>
...
<variable name="my.pkg.newrecord" >
<type
name="org.drools.process.core.datatype.impl.type.ObjectDataType"
className="my.pkg.Tablex"/>
</variable>
...
<workItem id="2" name="DBWorkItem" x="165" y="374" width="80"
height="40" >
<work name="DBWorkItem" >
</work>
<mapping type="in" from="my.pkg.tablename" to="my.pkg.tablename" />
<mapping type="in" from="my.pkg.newrecord" to="my.pkg.newrecord"/>
<mapping type="in" from="my.pkg.outlist" to="my.pkg.outlist"/>
</workItem>
</p>
In my manifest for my .rf file and for the flow manager (where the parsing
occurs) I Import-Package Tablex's package.
When my flow manager tries parsing the rule, it gives an error saying the
the import failed. BUT, everything still works, and my WorkItemHandler works
correctly (the WorkItemHandler imports Tablex itself, since it needs to
manipulate it).
If I declare my Tablex variable as a java.util.Object in the ruleflow then I
don't get the error and things also still work.
If I declare my Tablex as Tablex in the rule flow AND import it in the class
that does the parsing (it's already 'OSGI' imported to the parsing bundle,
but now I'm doing a plain old Java import on it) then everything works fine
with no error message.
Kind of a hybrid question but I figured I'd start with the Drools folks.
Any ideas would be appreciated.
Thanks,
Mike
--
View this message in context: http://www.nabble.com/OSGI%2C-classloading%2C-and-imports-in-KnowledgeBui...
Sent from the drools - user mailing list archive at Nabble.com.
15 years, 3 months
(no subject)
by Zevenbergen, Alex
Hi all,
This rule clause fails to evaluate, I am obviously missing something
fundamental - can somebody enlighten me?
rule "1st half Over 0.5 goals"
when
resultInfo : SoccerResultInfo(clockStage > (
CLOCK_STAGES.FIRST_HALF.getValue() ) , (homeHalfTimeScore +
awayHalfTimeScore) > 0 )
then
and this is the error
[ERR 103] Line 13:103 no viable alternative at input '+' in rule "1st
half Over 0.5 goals"
Thanks in advance
Alex
________________________________________________________________________
Privileged, confidential and/or copyright information may be contained in this communication. This e-mail and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you are not the intended addressee, you may not copy, forward, disclose or otherwise use this e-mail or any part of it in any way whatsoever. To do so is prohibited and may be unlawful. If you have received this email in error
please notify the sender immediately.
Paddy Power PLC may monitor the content of e-mail sent and received for the purpose of ensuring compliance with its policies and procedures.
Paddy Power plc, Airton House, Airton Road, Tallaght, Dublin 24 Registered in Ireland: 16956
________________________________________________________________________
15 years, 3 months
rule engines and data-source
by David Boaz
This question is related to application of rule engines in general, not
specifically to drools.
Typically, rule engines provide an API to insert facts to working-memory and
then executes the rules. In most of the applications, this data originates
from a data-source. It is the application responsibility to retrieve the
relevant data and to insert in to the engine. If for some reason the query
for data is too selective, the engine may end-up with wrong conclusions.
So, it is not enough to maintain the business-logic as rules only, there is
a need to maintain also the query.
What are the common patterns used by applications?
* retrieve all data regarding a subject (e.g., in the case of a clinical
application - the complete set of patient data). this may cause the
collection of large quantities of data (we know that the 'data-gathering'
step is much longer than processing it in a rule-engine)
* to retrieve only relevant data. Here we will try to restrict the data
retrieval only to data that may affect the rules. For example, in the case
of a clinical application, only the hemoglobin laboratory results from the
last 4 months. The issue here is that query is affected from the rules.
We'd like to automatically generate/ validate the data query according to
the rules logic.
I imagine is an analyzer that receives as input a knowledge-base and returns
the greatest-common-query (like GCD). The returned query can be expressed in
OCL for example.
Does drolls provides a meta-data API to analyze the rule WHEN part?
Thanks, David
--
View this message in context: http://www.nabble.com/rule-engines-and-data-source-tp25281811p25281811.html
Sent from the drools - user mailing list archive at Nabble.com.
15 years, 3 months
Different knowledge bases Vs One knowledge base with use of agent filters..?
by Kumar Mynam
Hello All,
We have different clinical models thru which we send patient data(HeartRate, MeanBP, etc...)
and alert clinicians with different kind of alerts based on output of model.
every clinical model has certain activation rules, alert rules. We are planning to use Drools for implementing those rules.
a .drl file is implemented for each model and rule type(activation rules, alert rules)
We are thinking about two different kinds of implementations.
1) Create a KnowledgeBase for each model and rule type. Now, when we want to evaluate data
thru model-1, we insert the facts into that particular model knowledge base statefulsession,
and fire the rules.
2) Create one big KnowledgeBase for all the models and rule types. Here, when we want to
evaluate data thru clinical model-1, we get a session out of KnowledgeBase, insert facts,
while firing rules we pass in agent filters to fire only model-1 rules.
Does 2nd approach have any advantages over the 1st approach. If so, what are those advantages,
or a link to that page would be greatly appreciated.
Thank you.
kumar.
15 years, 3 months
Re: [rules-users] Accumulator - Syntax question
by Joseph Berdat
Hello,
In attachment there are a DRL file and java test case which causes the
NPE mentionned below.
Thanks,
Regards
Exception in thread "main" java.lang.NullPointerException
at
org
.drools
.rule.builder.PatternBuilder.buildRestriction(PatternBuilder.java:948)
at
org
.drools
.rule.builder.PatternBuilder.buildRestriction(PatternBuilder.java:727)
at
org
.drools
.rule.builder.PatternBuilder.createRestriction(PatternBuilder.java:504)
at org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:
351)
at
org
.drools
.rule.builder.PatternBuilder.buildConstraint(PatternBuilder.java:239)
at org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:
196)
at org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:
104)
at
org
.drools
.rule.builder.GroupElementBuilder.build(GroupElementBuilder.java:69)
at org.drools.rule.builder.RuleBuilder.build(RuleBuilder.java:68)
at org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:1159)
at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:
649)
at
org
.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:
290)
at
org
.drools
.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:488)
at
org
.drools
.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:25)
at TestQuote.executeRule(TestQuote.java:37)
at TestQuote.main(TestQuote.java:19)
Le 3 sept. 09 à 22:06, PlugTree a écrit :
> hmmm seems we met a bug here. post it to the list to see if anyone
> knows something about it. If not I'll dig into the code to see the
> problem.
>
> Thanks!
> CEO
> plugtree.com
>
> Joseph Berdat wrote:
>> Hello,
>>
>> I've tried you proposition:
>> $quote : Quote(value > (Double() from accumulate( Quote( $price :
>> value ), average( $price ) ) ))
>> Unfortunatly, it produces the following error:
>> java.lang.NullPointerException
>> at
>> org
>> .drools
>> .rule.builder.PatternBuilder.buildRestriction(PatternBuilder.java:
>> 948)
>> at
>> org
>> .drools
>> .rule.builder.PatternBuilder.buildRestriction(PatternBuilder.java:
>> 727)
>> at
>> org
>> .drools
>> .rule.builder.PatternBuilder.createRestriction(PatternBuilder.java:
>> 504)
>> at org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:
>> 351)
>> at
>> org
>> .drools
>> .rule.builder.PatternBuilder.buildConstraint(PatternBuilder.java:239)
>> at org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:
>> 196)
>> at org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:
>> 104)
>> at
>> org
>> .drools
>> .rule.builder.GroupElementBuilder.build(GroupElementBuilder.java:69)
>> at org.drools.rule.builder.RuleBuilder.build(RuleBuilder.java:68)
>> at org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:
>> 1159)
>> at
>> org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:
>> 649)
>> at
>> org
>> .drools
>> .compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:290)
>> at
>> org
>> .drools
>> .compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:
>> 488)
>> at
>> org
>> .drools
>> .builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:25)
>> at
>> home.prototype.business.service.QuoteTest.loadRule(QuoteTest.java:62)
>> at home.prototype.business.service.QuoteTest.test1(QuoteTest.java:35)
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at
>> sun
>> .reflect
>> .NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>> at
>> sun
>> .reflect
>> .DelegatingMethodAccessorImpl
>> .invoke(DelegatingMethodAccessorImpl.java:25)
>> at java.lang.reflect.Method.invoke(Method.java:585)
>> at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
>> at
>> org
>> .junit
>> .internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
>> at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:
>> 79)
>> at
>> org
>> .junit
>> .internal
>> .runners
>> .MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)
>> at
>> org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
>> at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
>> at
>> org
>> .junit
>> .internal
>> .runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:
>> 88)
>> 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
>> .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)
>>
>> Regards,
>>
>> Le 3 sept. 09 à 10:52, Plug Tree Labs a écrit :
>>
>>> Joseph:
>>>
>>> I think you should need something like this:
>>>
>>> $quote : Quote(value > (Double() from accumulate( Quote( $price :
>>> value ), average( $price ) )))
>>>
>>> What do you think?
>>>
>>> joseph berdat wrote:
>>>> Hello,
>>>> The rule below check which quote have a price above the average.
>>>> In this form the rule is working, but from the log files it seems
>>>> that this rule is doing a cross join.
>>>> rule "above average value"
>>>> dialect "mvel"
>>>> when
>>>> Double( $average : doubleValue) from
>>>> accumulate( Quote( $price : value ), average( $price ) )
>>>> $quote : Quote(value > $average)
>>>> then
>>>> System.out.println("Quote above average [" + $quote.id + "]
>>>> value [" + $quote.value + "] average [" + $average + "]")
>>>> end
>>>> I could not get the correct syntax. I would like to write
>>>> something like:
>>>> when Quote(value > doubleValue) from accumulate( Quote( $price :
>>>> value ), average( $price ) )
>>>> Thanks,
>>>> regards.
>>>> ------------------------------------------------------------------------
>>>> _______________________________________________
>>>> rules-users mailing list
>>>> rules-users(a)lists.jboss.org <mailto:rules-users@lists.jboss.org>
>>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>
>>
>
15 years, 3 months
Drools Syntax
by Lindy hagan
Hi,
Could anyone tell me what will be the syntax to check for a list in the drl
file.
For ex:
If the user object contains userid (userId) and list of privileges
(privilegeList) values can be User Privilege or Admin Privilege.
I want to create 3 rules :
privilegeList.contains("User Privilege ") && privilegeList.contains("Admin
Privilege") first rule
privilegeList.contains("User Privilege ") second rule,
privilegeList.contains("Admin Privilege") third rule,
can this be done in Drools?
Thanks,
Lindy
15 years, 3 months
Scaling to large numbers of rules
by Adam Sussman
I am hoping that I am doing something wrong here and that one of you can
point me in the right direction.
Can anyone provide some advice on scaling up the number of rules in a
single KnowledgeBase? While I have seen all sorts of reports on having
lots of facts, I have not seen anything about having lots of rules.
I need to get to about 200K rules in a single KnowledgeBase, and also
to run several of these side by side in the same system.
The problem:
As the number of rules increases, the time to compile and load them
into memory skyrockets. Now while I realize that the Rete algorithm
complexity is about the number of rules, the times I am seeing are
pretty scary. Also, at about 30k rules, things just fall apart.
On a 64 bit Linux OS with 2 2.4Ghz processors using a 64bit JVM from
OpenJDK (1.6.1) with 1 Gig of memory allocated to the JVM, loading
from .drl files:
1000 rules:
KnowledgeBuilder.add: 7 seconds
KnowledgeBase.addKnowledgePackages: .8 seconds
10000 rules:
KnowledgeBuilder.add: 79 seconds
KnowledgeBase.addKnowledgePackages: 23 seconds
15000 rules:
KnowledgeBuilder.add: 138 seconds
KnowledgeBase.addKnowledgePackages: 55 seconds
20000 rules:
KnowledgeBuilder.add: 488 seconds
KnowledgeBase.addKnowledgePackages: 100 seconds
30000 rules:
KnowledgeBuilder.add: out of memory
KnowledgeBase.addKnowledgePackages: never runs
At this rate, 200k rules will take 13-14 hours to compile
and 2-3 hours to load into RAM, assuming I can even get
to that many rules. This just is not usable.
Time to fire all rules is negligible (fortunately!).
The rules I am testing on are very simple 1-3 variable equality whens
with a simple System.out.println then clause.
The benchmark code I am running is as follows:
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add( ResourceFactory.newClassPathResource( drlFile, RuleRunner.class ), ResourceType.DRL );
Collection<KnowledgePackage> pkgs = kbuilder.getKnowledgePackages();
kbase.addKnowledgePackages( pkgs );
Sample rule:
rule "00000005 - random rule"
when
Transaction(someId == 35156 && someOtherId == '79F81FB8134A129F' && someCollection contains 'EC3F2A1DCA88')
then
System.out.println("match rule 00000005 - random rule");
end
Any help would be appreciated.
Regards,
Adam Sussman
CONFIDENTIALITY NOTICE:
This message contains information which may be confidential or privileged. If you are not the intended recipient, be aware that any disclosure, copying, distribution or use of the contents of this information is prohibited. If you have received this transmission in error, please notify me immediately by telephone.
15 years, 3 months
Re: [rules-users] not able to debug drools flow
by Jakob Marovt
Hi,
I`m experiencing the same problems as Vishal. I am using Eclipse 3.5
and newest Drools. I am only able to debug project as Java
application, but when I want to debug it as Drools application all I
get is this problem. I also tried disabling firewall and changing its
settings but as it seems it does not help.
So if anyone has figured out a solution to this problem, I would
really appreciate an answer.
Thanks,
Jakob
probably related to your personal firewall:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6303969
http://www.techienuggets.com/Comments?tx=3786
I don't think this is a Drools specific issue.
Mark
Vishal Anand wrote:
>
**>* Hi,*
>
**>* *
>
**>* I am using Drools 5.0 and have create a simple application using *
>* drools flow, it runs perfectly but when trying to debug it as n drools *
>* application I get the following error:*
>
**>* *
>
**>* FATAL ERROR in native method: JDWP No transports initialized, *
>* jvmtiError=AGENT_ERROR_TRANSPORT_INIT(197)*
>
**>* ERROR: transport error 202: connect failed: Connection refused*
>
**>* ERROR: JDWP Transport dt_socket failed to initialize,
TRANSPORT_INIT(510)*
>
**>* JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports *
>* initialized [../../../src/share/back/debugInit.c:690]*
>
**>* *
>
**>* *
>
**>* While stack trace shows the following:*
>
**>* *
>
**>* *
>
**>* java.lang.IncompatibleClassChangeError: Expected static method *
>*org.drools.eclipse.launching.DroolsVMDebugger.renderCommandLine([Ljava/lang/String;)Ljava/lang/String;
*
>
**>* at org.drools.eclipse.launching.DroolsVMDebugger.run(Unknown Source)*
>
**>* at *
>*org.eclipse.jdt.launching.JavaLaunchDelegate.launch(JavaLaunchDelegate.java:101)
*
>
**>* at *
>*org.drools.eclipse.launching.DroolsLaunchConfigurationDelegate.launch(Unknown
*
>* Source)*
>
**>* at *
>*org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:853)
*
>
**>* at *
>*org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:703)
*
>
**>* at *
>*org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:866)
*
>
**>* at *
>*org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1069)
*
>
**>* at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)*
>
**>* *
>
**>* *
>
**>* I am using eclipse 3.4*
>
**>* *
>
**>* What could be the issue ?*
>
**>* *
>
**>* Thanks*
>
**>* Vishal*
>
**>*------------------------------------------------------------------------
*
>
**>* _______________________________________________*
>* rules-users mailing list*
>* rules-users at lists.jboss.org<http://lists.jboss.org/mailman/listinfo/rules-users>
*
**>* https://lists.jboss.org/mailman/listinfo/rules-users*
**>* *
15 years, 3 months