Looking for a place to start with drools
by Dean Whisnant
I am investigating using Drools for our company's EDI processing. The nature of our software system is that each of our clients (dozens) has a full distribution of our base software and in the past we would make custom changes to that base software at each of their sites based upon their trading partners and business needs. For the most part these changes involved nothing more than if-then statements for rather simple logic, but that would become complicated at certain customers where there were large numbers of trading partners and specific customer needs. In general we saw 2,000 lines of code swell to 4-6,000 lines of code.
We are in the process of rewriting this portion of our code and are entertaining using drools to allow us to 1) create a standard ruleset, 2) create a ruleset specific to a trading partner (many customers share some common trading partners), and 3) create a customer business ruleset that they can maintain through some GUI tool (Guvnor).
So far, I've created a sample java program that has classes representing some of our data files (UniData environment using uniobjects) and have been working with a single .drl file to test out general rules. I appear to be able to write just about any rule I've needed in the past with no issues, including rules that spawn processes within my native software.
These are my questions:
1. How would you package these types of rules? I have three categories as stated above and it seems logical that I would package them in that manner. However within each group there are logical groupings of rules. In the customer rules I may have a couple dozen on how to populate a field that deals with adding comments and another couple dozen having to deal with setting certain fields with specific codes that are based upon incoming data. Two quite different logical areas within our software.
2. How would you deal with the GUI? Is Guvnor truly something I can setup in a way that my end users can manipulate without "damaging" the custom ruelset?
3. Within Guvnor, how would you handle the possibility of there being over 2,000 fields to choose from to form a rule?
4. What is the performance hit if we were to make each customer rule part of once decision table or another? Would you even consider this as an option?
Thank you!
--Dean
15 years, 7 months
Rule id / Rule name
by Nadav Hashimshony
Hi,
I would like to return to the Fact object the rule id that was caught
my facts class has a memeber
String caughtRule;
and set and get
setCaughtRuleId (String s) { caughtRule= s;}
String getCaughtRuleId () {return caughtRule;}
my rule looks like:
rule "01"
salience 100
activation-group "mygrp"
no-loop true
when
d : CFactClass( someMember matches "some-string");
then
System.out.println("01 caught");
d.setCaughtRuleId("01");
d.setCaught();
end
when the rule is fired i see the the setCaught() worked (its a boolean
variable) but the setCaughtRuleId methids return empty string...
any ides?
Thanks
Nadav,.
15 years, 7 months
Memory usage tied to rule report?
by Jared Davis
Hi,
I'm attempting to track down an out of memory error.
I have ~400 rules that operate on ~10000 facts. One set of facts throws an
out of memory error while other sets process w/o an error. It is easy to
reproduce.
When the system runs out of memory there are about 22,000,000 ReteTuple
objects active.
I assume I have a bad rule producing a large cross product.
How do I find it?
Is there an audit tool that will let me tie ReteTuple back to a specific
rule?
Regards,
Jared Davis
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Memory-usage-tied-to-...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 7 months
Could not initialize class org.drools.rule.builder.dialect.java.JavaDialect
by Donald Leuschner
Ok, I have been struggling with this error for days now. I am getting a
NoClassDefFoundError: Could not initialize class
org.drools.rule.builder.dialect.java.JavaDialect error.
I understand that this is most likely a classpath problem but have done
almost everything to try and resolve it. I have the
drools-compiler-5.1.0.jar in my lib folder where all my other jars are
(which successfully work btw) and adding this jar there resolves a
packagebuilder error also.
Does anyone have any idea? The JavaDialect.class files are in the jar if I
open it with 7zip...so it's not like they are not there. I'm really at a
loss with this one now.
15 years, 7 months
OOME on JPA persistence of stateful session
by dan.danciu
Hi,
I'm trying to use JPA persistence for a stateful session (version 5.1.1),
the configuration is made using spring integration support.
During the integration tests almost always I get an OutOfMemoryException. I
chased the problem to the piece of code bellow (from
org.drools.marshalling.impl.OutputMarshaller).
The "for" statement marked "HERE" will cycle for ever (until no more memory
is left).
I also found the
http://www.mail-archive.com/rules-users@lists.jboss.org/msg12427.html
thread, I took out my split, but problem did not go away.
Cheers,
Dan
case NodeTypeEnums.ForallNotNode : {
if ( leftTuple.getBlocker() == null ) {
// is not blocked so has children
stream.writeShort( PersisterEnums.LEFT_TUPLE_NOT_BLOCKED
);
///////////// HERE
for ( LeftTuple childLeftTuple = leftTuple.firstChild;
childLeftTuple != null; childLeftTuple = (LeftTuple)
leftTuple.getLeftParentNext() ) {
stream.writeShort( PersisterEnums.LEFT_TUPLE );
stream.writeInt(
childLeftTuple.getLeftTupleSink().getId() );
writeLeftTuple( childLeftTuple,
context,
recurse );
}
stream.writeShort( PersisterEnums.END );
} else {
stream.writeShort( PersisterEnums.LEFT_TUPLE_BLOCKED );
stream.writeInt(
leftTuple.getBlocker().getFactHandle().getId() );
}
break;
}
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/OOME-on-JPA-persisten...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 7 months
Matching strings in two arrays
by Kumar Pandey
Drools 5.1.0
I have a need to match list of incoming strings to those in the rule. All
the strings in the fact object needs to exists in the rule.
I have a large set of rules around 5000.
In general I have around 4 conditions per rule and its taking in average
around 30- ~40 ms to go through the 5000 rules.
However the following construct that I am using to match the incoming set of
input strings is adding on the average 200ms to rules execution.
Is there a more efficient way to do this?
MyContext is the fact class and classes is array of String.
I need to make sure that the classes array contains all three
strings TestString1, TestString2 and TestString3.
MyContext(DclassesList : classes)
exists( String(this matches "TestString1") || String(this matches
"TestString2") || String(this matches "TestString3") from DclassesList)
Of course each rule in the 5000 can have diff set of strings to match.
Thanks
15 years, 7 months
Connect to Guvnor from other machines.
by Nadav Hashimshony
Hi
i have drools guvnor installed on my machine, i can access it with localhost
or with my ip.
when i want to access the guvnor from other machines i cant.
is there some settings i need to do?
thanks.
Nadav.
15 years, 7 months
Spring , Ruleflow and KnowledgeBuilderConfiguration
by Swindells, Thomas
I'm using drools flow in my spring application and am currently using the following to configure the kbase I use:
<drools:kbase id="ingestKbase">
<drools:resources>
<drools:resource type="DRL"
source="classpath:ingest/drools/ingest.drl" />
<drools:resource type="DRF"
source="classpath:ingest/drools/ingest.rf" />
</drools:resources>
<drools:configuration>
<drools:mbeans enabled="true" />
</drools:configuration>
</drools:kbase>
When I run I'm getting a big error:
Process Compilation error : org.drools.lang.descr.ProcessDescr@7a40fc
vcm/ingest/Process_vcm_ingest_0.java (7:281) : Syntax error on tokens, ( expected instead
vcm/ingest/Process_vcm_ingest_0.java (7:281) : The left-hand side of an assignment must be a variable ...
Firstly it looks like ProcessDescr needs a sensible toString method implemented - preferably actually saying which resource it is attempting to compile.
I'm guessing that I've got some syntax errors in my ruleflow file (even though the eclipse plugin claims it validates fine).
I've seen that the knowledge builder configuration has the option drools.dump.dir, but how can I set this within Spring?
Thanks,
Thomas
________________________________
**************************************************************************************
This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmaster(a)nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary.
NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00
**************************************************************************************
15 years, 7 months
Re: [rules-users] fireUntilHalt and timing of rule activations
by Greg Barton
If you don't have some way of associating the data with a particular Latch it's easy to get overlap when processing datasets. In general you need some way to group the data together. You can avoid a back reference to the Latch by having a Set of some sort in the Latch to which you add all data in the batch. If you use a Set backed by an IdentityHashMap the overhead is pretty small, and rules look like this:
rule "CountAs"
dialect "java"
salience -1
when
l : Latch()
a : A( this memberOf l.dataSet )
then
retract(a);
l.incACount();
System.out.println("Found an A in " + l);
end
See attached project.
THough I like the cleverness of using the "data in matched objects alters rule properties" trick, you could have just as easily had a "Latch(value == true)" conditional, and that would be more clear, IMO. I'm curious to see of the enabled trick would perform better, though.
GreG
--- On Sun, 10/3/10, Wolfgang Laun <wolfgang.laun(a)gmail.com> wrote:
From: Wolfgang Laun <wolfgang.laun(a)gmail.com>
Subject: Re: [rules-users] fireUntilHalt and timing of rule activations
To: "Rules Users List" <rules-users(a)lists.jboss.org>
Date: Sunday, October 3, 2010, 4:23 AM
There is another way of associating a Latch object with rules, without having to store a reference to a Latch in objects:
rule "CountAs"
enabled ( $v )
when
Latch( $v : value )
X( ... )
then ... end
At the beginning, insert Latch( false ), which blocks all rules with this construction, or modify the Latch object to false before inserting more facts. Then, insert the facts, and, at the end, modify Latch to true.
Latch latch = new Latch( true );
FactHandle fh = kSession.insert( latch );
kSession.fireAllRules();
latch.setValue( false );
kSession.update( fh, latch );
Of course, you can use multiple Latch objects, adding a name field with a specific value, so that a latch applies to a subset of rules only:
rule "CountAs"
enabled ( $v )
when
Latch( name == "CountAs", $v : value )
...
But be aware that changes to Latch objects will retrigger rules that have fired previously; so with this approach you'll have to make sure to retract facts when they have been processed.
-W
2010/10/3 Greg Barton <greg_barton(a)yahoo.com>
Nope, you're not missing anything. What you need is a control object of some sort thst's inserted after all of the "real" data is inserted. (See attached project for an example.) Rules will look like this, if the control object is called BatchLatch and data objects A:
rule "CountAs"
dialect "java"
salience -1
when
l : Latch()
a : A( latch == l )
then
retract(a);
l.incACount();
System.out.println("Found an A in " + bl);
end
Note that the A object being processed is tied back to the latch. This is so multiple latches can be processed simultaneously and their processing won't be intermingled. This is necessary because there's no guarantee that two Latch objects aren't in working memory at once. (Though you could create a rule that enforces this.)
GreG
--- On Sat, 10/2/10, Norman C <rent_my_time(a)yahoo.com> wrote:
> From: Norman C <rent_my_time(a)yahoo.com>
> Subject: [rules-users] fireUntilHalt and timing of rule activations
> To: rules-users(a)lists.jboss.org
> Date: Saturday, October 2, 2010, 10:22 AM
> Hi All,
>
> In my app, I have a separate thread calling fireUntilHalt()
> continuously. I
> have quite a few rules, and I am using salience extensively
> to control the order
>
> in which rules are executed. What I have seen (by adding
> an event listener) is
> that as a new fact is inserted, various rules are
> activated. Often, the
> fireUntilHalt will start executing fireNextItem in
> DefaultAgenda before all of
> the activations are complete. So if the rule with the
> highest salience
> value hasn't been activated at this point, then the first
> rule to be fired isn't
>
> the correct one.
>
> This can be worked around by waiting for insert to return
> and then calling
> fireAllRules(). But it seems like the session should
> block fireUntilHalt from
> trying to execute activated rules until all activations are
> complete. Or am I
> missing something here?
>
> thanks,
> Norman
>
>
>
>
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
-----Inline Attachment Follows-----
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
15 years, 7 months
nested condition in from collect
by lnguyen
I'm trying to determine if a user has a certain immunization on record or a
group of immunizations but when I attempt to put additional the rule will
not compile.
rule "Immunizations_Determine if a user has a valid tetanus immunization"
dialect 'mvel'
no-loop true
salience 100
when
$user : User($profile : profile)
$got : List() from collect ( UserImmunization( immunization != null,
eval( immunization.immunizationName == "Td or Tet/Dip (Tetanus/Diphtheria)"
|| immunization.immunizationName == "Tdap (Tetanus/Diphtheria & Pertussis)"
|| immunization.immunizationName == "DT (Diphtheria/Tetanus)" ||
immunization.immunizationName == "TT or Tet Tox (Tetanus Toxoid)" ||
immunization.immunizationName == "Tetanus")) from $profile.userImmunizations
)
then
System.out.println("The user has has a valid tetanus immunization ");
end
The profile contains a list of UserImmunizations.
UserImmunizations:
private Long id;
private Immunization immunization;
private Date dateReceived;
Immunizations:
private Long id;
private String immunizationName;
I'm not sure if this is a good place to use 'from accumulate'.
Is it possible to do the condition for the Immunization object within the
'from collect' or should it be evaluated separately?
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/nested-condition-in-f...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 7 months