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, 9 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, 9 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, 9 months
Error in named query: ProcessInstancesWaitingForEvent
by Eugenio Abello
Hi, I'm using drools 5.1.1 with persistent flow and Human Task. In orm.xml
are queries Flow and HT. But among this error initializing JPA:
ERROR 24-09 17:20:36,375 - Error in named query:
ProcessInstancesWaitingForEvent
org.hibernate.QueryException: cannot dereference scalar collection element:
name [select processInstanceInfo.processInstanceId from
org.drools.persistence.processinstance.ProcessInstanceInfo
processInstanceInfo where :type in
(processInstanceInfo.eventTypes.name<http://processinstanceinfo.eventtypes.name/>
)]
thanks
15 years, 9 months
Drools with Spring Batch
by Manav
Hi,
I am trying to integrate Drools with Spring Batch. Is there some documentation
that could throw some light on the configuration involved in the same.
Regards,
Manav
15 years, 9 months
Using CGLIB BeanGenerator as fact object
by Kumar Pandey
I'm exploring the possibility of using a dynamic bean as fact object as my
fact object is very dynamic in nature.
I came across posts where people had recommended using BeanGenerator from
CGLIB.
This blog does a very good job of explaining the details of classloader
etc.
http://blog.athico.com/2006/12/dynamically-generated-class-beans-as.html
>From what I can gather ( I'm new to both CGLIB and drools ) CGLIB seems to
have the lowest lerning curve to achieve this.
I have the below sample on creating a dynamic bean with CGLIB
BeanGenerator bg = new BeanGenerator();
bg.setSuperclass(FactContextPlaceHolder.class);
bg.setNamingPolicy(new net.sf.cglib.core.NamingPolicy() {
public String getClassName(String prefix, String source, Object key,
Predicate names) {
return prefix + "Impl";
}
});
bg.addProperty("foo", Double.TYPE);
g.addProperty("bar", String.class);
FactContextPlaceHolder beanInst = (FactContextPlaceHolder)bg.create();
Here com.drools.test.FactContextPlaceHolder is set as super class and the
generated class is obtained as com.drools.test.FactContextPlaceHolderImpl
I have two basic question I am unable to find some answers on.
1) Once I create an object, how do I actually set the state of this object
with fact values before setting it as fact object to drools session?
In the above example how do I set value of foo to "foot-test1" and value of
bar to "bar-test1" on the beanInst.
2) In DRL if I set the package to some path say com.drools.test
Should I then use FactContextPlaceHolderImpl as my fact Object?
Thanks
Kumar
15 years, 9 months
Drools Flow Events Not Working
by jawa
Hi,
I am using drools flow 5.1.1 with JPA. I want my flow to stop at a certain
point so I use an AND node with one incoming RuleGroup node and one incoming
Event node. so as AND guarantees that It executes after both of the nodes
are completed. So my flow stops there. Then i load the session from db and
use following to raise an event on the session:
StatefulKnowledgeSession session =
JPAKnowledgeService.loadStatefulKnowledgeSession(9,knowledgeBase, null,
environment);
ProcessInstance p = session.getProcessInstance(9);
System.out.println("Proc Found -> " + p);
if (p != null && p.getState()==ProcessInstance.STATE_ACTIVE)
{
p.signalEvent("Test", vo);
}
But it fails with following exception:
Exception in thread "main" java.lang.NullPointerException
at
org.drools.process.instance.impl.ProcessInstanceImpl.getProcess(ProcessInstanceImpl.java:67)
at
org.drools.workflow.instance.impl.WorkflowProcessInstanceImpl.getWorkflowProcess(WorkflowProcessInstanceImpl.java:185)
at
org.drools.workflow.instance.impl.WorkflowProcessInstanceImpl.signalEvent(WorkflowProcessInstanceImpl.java:346)
at com.my.poc.PocFlowServiceImpl.processFlow(PocFlowServiceImpl.java:120)
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:597)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeTarget(MethodInvocation.java:122)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:111)
at
org.jboss.ejb3.EJBContainerInvocationWrapper.invokeNext(EJBContainerInvocationWrapper.java:69)
at
org.jboss.ejb3.interceptors.aop.InterceptorSequencer.invoke(InterceptorSequencer.java:73)
at
org.jboss.ejb3.interceptors.aop.InterceptorSequencer.aroundInvoke(InterceptorSequencer.java:59)
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:597)
at
org.jboss.aop.advice.PerJoinpointAdvice.invoke(PerJoinpointAdvice.java:174)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at
org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor.fillMethod(InvocationContextInterceptor.java:72)
at
org.jboss.aop.advice.org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor_z_fillMethod_20004366.invoke(InvocationContextInterceptor_z_fillMethod_20004366.java)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at
org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor.setup(InvocationContextInterceptor.java:88)
at
org.jboss.aop.advice.org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor_z_setup_20004366.invoke(InvocationContextInterceptor_z_setup_20004366.java)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at
org.jboss.ejb3.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:62)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at
org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:56)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at
org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at
org.jboss.ejb3.tx.StatelessBMTInterceptor.handleInvocation(StatelessBMTInterceptor.java:106)
at org.jboss.ejb3.tx.BMTInterceptor.invoke(BMTInterceptor.java:55)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at
org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:68)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at
org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at
org.jboss.ejb3.security.Ejb3AuthenticationInterceptorv2.invoke(Ejb3AuthenticationInterceptorv2.java:186)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at
org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:41)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at
org.jboss.ejb3.BlockContainerShutdownInterceptor.invoke(BlockContainerShutdownInterceptor.java:67)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at
org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor.invoke(CurrentInvocationInterceptor.java:67)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at
org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:421)
at
org.jboss.ejb3.session.InvokableContextClassProxyHack._dynamicInvoke(InvokableContextClassProxyHack.java:53)
at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:91)
at
org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:891)
at
org.jboss.remoting.transport.socket.ServerThread.completeInvocation(ServerThread.java:744)
at
org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:697)
at
org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:524)
at
org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:232)
at
org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientInvoker.java:211)
at org.jboss.remoting.Client.invoke(Client.java:1724)
at org.jboss.remoting.Client.invoke(Client.java:629)
at
org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:60)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at
org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:61)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at
org.jboss.ejb3.security.client.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:65)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at
org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:74)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.aspects.remoting.PojiProxy.invoke(PojiProxy.java:62)
at $Proxy3.invoke(Unknown Source)
at
org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.invoke(SessionProxyInvocationHandlerBase.java:207)
at
org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.invoke(SessionProxyInvocationHandlerBase.java:164)
at $Proxy2.processFlow(Unknown Source)
at net.plus.kbd.poc.StartFlow.main(StartFlow.java:39)
at
org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:72)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at
org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:61)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at
org.jboss.ejb3.security.client.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:65)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at
org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:74)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.aspects.remoting.PojiProxy.invoke(PojiProxy.java:62)
at $Proxy3.invoke(Unknown Source)
at
org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.invoke(SessionProxyInvocationHandlerBase.java:207)
at
org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.invoke(SessionProxyInvocationHandlerBase.java:164)
at $Proxy2.processFlow(Unknown Source)
at com.my.poc.StartFlow.main(StartFlow.java:39)
Then i tried to use this code:
SignalEventCommand command = new SignalEventCommand();
command.setProcessInstanceId(9);
command.setEventType("Test");
command.setEvent(true);
session.execute(command);
But it fails:
Exception in thread "main" java.lang.NoSuchMethodError:
org.drools.runtime.StatefulKnowledgeSession.execute(Lorg/drools/command/Command;)Lorg/drools/runtime/ExecutionResults;
at com.my.poc.PocFlowServiceImpl.processFlow(PocFlowServiceImpl.java:127)
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:597)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeTarget(MethodInvocation.java:122)
Although I have drools jars in my classpath. All required jars including
drools-core-5.1.1.jar
Any idea how can i raise an event ??
Thanks
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Drools-Flow-Events-No...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 9 months
Drools Flow process question...
by bob.breitling
I have a very simple process with one RuleFlow Group.
I am registering an object via the variables.
I have several rules which I am trying to get to fire.
I have rules which constraints on the object I registered that are not
working. I have rules with constraints on the WorkflowProcess I insert that
are not working unless I include another rule with no constraints. When I
debug the Drools code, and I include the rule without constraints, I see the
default agenda-group returning. Without the rule, the agenda-group is
always null. Therefore none of my rules fire. I have yet to get a rule
with constraints based on variables registered in my process to work. I am
basically following the examples from my Drools book.
I am using 5.1.1 jars.
Any help would be greatly appreciated.
TIA,
Bob
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Drools-Flow-process-q...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 9 months
Drools flow variables don't get passed to sub process?
by jawa
Hi,
I've a drools flow which has sub flow node in it. I've create a drools flow
variable both in main flow and sub flow with the same name. Then I use that
variable to set Parameter Mappings of a work item with in my main flow and
in sub flow. The work items in main flow get it fine and works perfectly but
the sub flow work items complain that it couldn't fine parameter. Here is
what i get in logs:
16:43:59,379 ERROR [STDERR] Could not find variable scope for variable
myvo.comment
16:43:59,380 ERROR [STDERR] when trying to execute Work Item My Workitem
16:43:59,380 ERROR [STDERR] Continuing without setting parameter.
In my code i start main flow with a map of parameter called "myvo" and I
assumed that the same variable will be passed to sub flow automatically but
it didn't. Does anyone know how can i pass the parameter to my sub flow ?
Thank you
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Drools-flow-variables...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 9 months