A quick survey of application areas
by Wolfgang Laun
Folks who have a wider view of Drools Expert (not Flow, Fusion, Guvnor,
Solver) are
kindly invited to post application areas where plain Drools Expert has been
put to good use.
This will be used as bolstering in a survey paper I'm writing for a local
journal
(focussing on applications for railway interlocking and similar, which I
know well
enough myself).
Application areas I'm aware of are:
- insurance: applications and claims
- banking: loan application
- stockkeeping/warehousing
- medicine: analysis of diagnostic findings
- text processing: text analysis & classification
- billing: pricing, trade allowance
So, if you know other mainstream application areas, please reply.
Thank you
Wolfgang
16 years, 2 months
drl to pkg
by Perumaal Krishnaraj
Hello Everybody,
I'm a newbie to Drools, so please excuse me, if question is very
fundamental.
I'm not using drools with eclipse or brms.
I would like to convert the drl file which I had created using a text editor
to the binary form ie. in pkg format (serialized), which can be used im my
Java application.
Is there a tool, or a code snippet which gives me an idea as to how this is
done.
Regards,
kp
16 years, 2 months
Re-sending : Unexpected MVEL plus operator behavior (string-to-double), in consequence block
by Kinshuk Adhikary
Using
drools 5.1
mvel 2-2.0.14
In consequence (then) block : (dialect strict or not does not make a difference)
Trying to sum up some numbers after a multiplication operation. For example :
t.out = t.in2*t.in3 + t.in3*t.in4 + t.in2*t.in4;
(the object t has all its attributes of the type String), all the t.in parameters are actually numbers-as-strings.
So the multiplication is going on fine, as expected, but the addition (+) sign, is concatenating instead of adding.
So the for inputs "1", "2" and "3", the result looks something like : 2.06.03.0 (i.e concetenated) instead of the expected 11.0.
What is going worng How does the + operator decide to do concat instead of doing addition.
Any documentation on this + operator logic ?
Note : The above works fine when I use MVEL without Drools.
Thanks
16 years, 2 months
functions
by Chris Richmond
Ok.I am trying to build a function library in my .drl file and I added this
one test function
function String outputString(String sData){
return sData;
}
And no matter where I place this in my .drl file, I get an exception one way
or the other with compiling when I try instaniate and fire my rules. The
.drl file works exactly as expected if I remove this function declaration,
and when I *do* try to add it, I do not actually call it anywhere.but get
those errors.
So my question is, where exactly do I need to place function declarations..
Thanks,
Chris
16 years, 2 months
Returned mail: see transcript for details
by Returned mail
The original message was received at Sun, 20 Dec 2009 12:47:51 +0530
from lists.jboss.org [206.112.172.244]
----- The following addresses had permanent fatal errors -----
<rules-users(a)lists.jboss.org>
----- Transcript of the session follows -----
... while talking to host 96.19.195.187:
>>> RCPT To:<rules-users(a)lists.jboss.org>
<<< 550 5.1.1 <rules-users(a)lists.jboss.org>... User unknown
16 years, 2 months
Unexpected MVEL + operator behavior (string<->double), in consequence block
by Kinshuk Adhikary
Using
drools 5.1
mvel 2-2.0.14
In consequence (then) block : (dialect strict or not does not make a difference)
Trying to sum up some numbers after a multiplication operation. For example :
t.out = t.in2*t.in3 + t.in3*t.in4 + t.in2*t.in4;
(the object t has all its attributes of the type String), and all the t.in parameters are actually numbers-as-strings.
So the multiplication is going on fine, as expected, but the addition (+) sign, is concatenating instead of adding.
So the for inputs "1", "2" and "3", the result looks something
like : 2.06.03.0 (i.e concetenated) instead of the expected 11.0.
What is going worng How does the + operator decide to do concat instead of doing addition.
Any documentation on this + operator logic ?
Note : The above works fine when I use MVEL without Drools.
Thanks
16 years, 2 months
Inconsistent results in fusion
by RichardA
Hi all again,
I am having a problem where the results of the rules is not consistent.
I am using rules flow and fireUntilHalt..
Here is most of my code: (expanding the default drools example)
private static KnowledgeBase readKnowledgeBase() throws Exception {
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("Sample.drl"),
ResourceType.DRL);
kbuilder.add(ResourceFactory.newClassPathResource("Flow.rf"),
ResourceType.DRF);
KnowledgeBuilderErrors errors = kbuilder.getErrors();
if (errors.size() > 0) {
for (KnowledgeBuilderError error: errors) {
System.err.println(error);
}
throw new IllegalArgumentException("Could not parse knowledge.");
}
KnowledgeBaseConfiguration conf =
KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
conf.setOption(EventProcessingOption.STREAM);
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(conf);
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
return kbase;
}
public static final void main(String[] args) {
try {
// load up the knowledge base
KnowledgeBase kbase = readKnowledgeBase();
final StatefulKnowledgeSession ksession =
kbase.newStatefulKnowledgeSession();
new Thread(new Runnable() {
public void run() {
ksession.fireUntilHalt();
}
}, "FireAllRules").start();
// go !
for(int i=0;i<50;i++){
Message message = new Message();
message.setMessage("one");
ksession.insert(message);
ksession.startProcess("myflow");
}
System.out.println("Sleeping");
Thread.sleep(20000);
System.out.println("Halt");
ksession.halt();
} catch (Throwable t) {
t.printStackTrace();
}
}
So, notice fireUntilHalt is started in a thread.
And its in STREAM mode
and I use flow group and sample rules set.
Then inject 50 messages, and after each inject start the 'myflow'
The rule flow is like this;
Start-> One -> Two -> Three -> End
and the rules are:
rule "One"
ruleflow-group "One"
when
m : Message( message=="one" )
then
m.setMessage( "two" );
update( m );
end
rule "Two"
ruleflow-group "Two"
when
m : Message( message=="two" )
then
m.setMessage( "three" );
update( m );
end
rule "NotThree"
ruleflow-group "Three"
when
m : Message( message!="three" )
then
System.out.println( "Message is not three????????????" );
retract(m);
end
rule "Three"
ruleflow-group "Three"
when
m : Message( message=="three" )
then
retract(m);
end
So, from that you should see that as an object is injected it has
message=="one"
so flow group One should match, the message updates to 'two'
then flow group two should match, message updates to 'three'
and then the group three rule Three should match and the object retracted.
Sometimes I run this I get results as expected.
Other times I get 1 message hit the 'NotThree' rule.
Other times I get lots of them hit the 'NotThree' rule.
Sometimes I get;
Exception in thread "FireAllRules"
org.drools.runtime.rule.ConsequenceException: org.drools.FactException:
Retract error: handle not found for object: null. Is it in the working
memory?
at
org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:23)
Its driving me mad as my project is failing due to inconsistent results.
Please help..
--
View this message in context: http://n3.nabble.com/Inconsistent-results-in-fusion-tp93259p93259.html
Sent from the Drools - User mailing list archive at Nabble.com.
16 years, 2 months
ProcessInstance Does Not Complete With User Task and Rule Task
by nfox241
I have a flow: start -- User Task - Rule Task - User Task - Action - end.
I complete the 1st User Task, next the rules which are part of the
RuleFlowGroup in the Rule Task fire correctly, then I complete the next User
Task. However, my final action node is never reached and the processInstance
never completes.
Here is my Rule Flow:
?xml version="1.0" encoding="UTF-8"?>
<process xmlns="http://drools.org/drools-5.0/process"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:schemaLocation="http://drools.org/drools-5.0/process
drools-processes-5.0.xsd"
type="RuleFlow" name="droolsflow" id="org.plugtree.labs.droolsflow"
package-name="org.plugtree.labs" >
<header>
<imports>
<import name="org.plugtree.labs.variablepersistence.MyEntity" />
<import
name="org.plugtree.labs.variablepersistence.MyVariableSerializable" />
</imports>
</header>
<nodes>
<ruleSet id="17" name="ruleMe" x="410" y="123" width="80" height="48"
ruleFlowGroup="fox" />
<start id="1" name="Start" x="16" y="16" width="48" height="48" />
<end id="3" name="End" x="665" y="312" width="48" height="48" />
<humanTask id="23" name="User Task" x="279" y="237" width="100"
height="48" >
<work name="Human Task" >
<parameter name="ActorId" >
<type
name="org.drools.process.core.datatype.impl.type.StringDataType" />
</parameter>
<parameter name="Comment" >
<type
name="org.drools.process.core.datatype.impl.type.StringDataType" />
</parameter>
<parameter name="Content" >
<type
name="org.drools.process.core.datatype.impl.type.StringDataType" />
</parameter>
<parameter name="Priority" >
<type
name="org.drools.process.core.datatype.impl.type.StringDataType" />
</parameter>
<parameter name="Skippable" >
<type
name="org.drools.process.core.datatype.impl.type.StringDataType" />
</parameter>
<parameter name="TaskName" >
<type
name="org.drools.process.core.datatype.impl.type.StringDataType" />
</parameter>
</work>
</humanTask>
<humanTask id="22" name="User Task" x="145" y="86" width="100"
height="48" >
<work name="Human Task" >
<parameter name="ActorId" >
<type
name="org.drools.process.core.datatype.impl.type.StringDataType" />
</parameter>
<parameter name="Comment" >
<type
name="org.drools.process.core.datatype.impl.type.StringDataType" />
</parameter>
<parameter name="Content" >
<type
name="org.drools.process.core.datatype.impl.type.StringDataType" />
</parameter>
<parameter name="Priority" >
<type
name="org.drools.process.core.datatype.impl.type.StringDataType" />
</parameter>
<parameter name="Skippable" >
<type
name="org.drools.process.core.datatype.impl.type.StringDataType" />
</parameter>
<parameter name="TaskName" >
<type
name="org.drools.process.core.datatype.impl.type.StringDataType" />
</parameter>
</work>
</humanTask>
<actionNode id="12" name="Finish" x="494" y="254" width="80" height="48"
>
<action type="expression" dialect="mvel"
>System.out.println("Finished!!!");</action>
</actionNode>
</nodes>
<connections>
<connection from="22" to="17" />
<connection from="12" to="3" />
<connection from="17" to="23" />
<connection from="1" to="22" />
<connection from="23" to="12" />
</connections>
</process>
And test code:
KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add( new ClassPathResource(
"VariablePersistenceStrategyProcess.rf" ), ResourceType.DRF );
kbuilder.add( new ClassPathResource( "myRules.drl" ),
ResourceType.DRL );
for (KnowledgeBuilderError error: kbuilder.getErrors()) {
System.out.println(error);
}
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
EntityManagerFactory emf =
Persistence.createEntityManagerFactory("org.drools.persistence.jpa");
Environment env = KnowledgeBaseFactory.newEnvironment();
env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);
StatefulKnowledgeSession ksession =
JPAKnowledgeService.newStatefulKnowledgeSession( kbase, null, env );
int id = ksession.getId();
System.out.println("### Starting process ###");
WorkflowProcessInstance processInstance = (WorkflowProcessInstance)
ksession.startProcess( "org.plugtree.labs.droolsflow"
/*,parameters*/ );
TestWorkItemHandler handler = TestWorkItemHandler.getInstance();
WorkItem workItem = handler.getWorkItem();
ksession = JPAKnowledgeService.loadStatefulKnowledgeSession( id,
kbase, null, env );
processInstance = (WorkflowProcessInstance)
ksession.getProcessInstance( processInstance.getId() );
ksession.getWorkItemManager().completeWorkItem( workItem.getId(),
null );
workItem = handler.getWorkItem();
ksession = JPAKnowledgeService.loadStatefulKnowledgeSession(id,
kbase, null, env);
processInstance = (WorkflowProcessInstance)
ksession.getProcessInstance(processInstance.getId());
System.out.println("### Completing second work item ###");
ksession.getWorkItemManager().completeWorkItem(workItem.getId(), null);
--
View this message in context: http://n3.nabble.com/ProcessInstance-Does-Not-Complete-With-User-Task-and...
Sent from the Drools - User mailing list archive at Nabble.com.
16 years, 2 months
timestamps fusion
by Khalil Hafsi
Hi Guys,
I am using last version of fusion.
do events in stream mode get automatic timestamps ? do I need to change
my Event class like in the broker example (in the way of
Event<stockTick> ) ?
class Event{
int symbol;
int load;
}
say if I have a simple code :
..drools initiation.. (stream mode)
session.insert(event(1,10))
session.insert(event(1,20))
session.insert(event(1,30))
should I for every new event fireallRules ?
What about salience , where can I get documentation about it ?
Thank you,
h-
16 years, 2 months