Preventing re-evaluation on modification of 'output' fact
by Jamie
We're building a fraud detection application that uses rules to analyze
orders and the buyers and recipients on those orders. As rules fire, they
modify an 'output' fact, which is an object whose only intent is to record
the results as rules fire. It's not used in the LHS of any rules other than
to get a handle to it, e.g.:
rule "Rule 001 - Operator Flagged"
enabled (FraudRuleEvaluationHelper.isRuleEnabled("Rule 001 - Operator
Flagged"))
ruleflow-group "orderAnalysis"
lock-on-active
when
$order: OrderFact(operatorFlagged==true)
$results: FraudResultsDTO()
then
modify($results) {
addOrderSuspectReason("O")
};
FraudRuleConsequenceHelper.logRuleFiring($order.getOrderId(), "001");
end
We're finding that as the number of facts increases, the processing team
increases dramatically and I'm wondering if modifying the output fact the
way we do causes the rules to get re-evaluated to see if any activations
should be created or cancelled. Would removing the modify block help
anything? Should we be thinking about this in some other way?
--
View this message in context: http://drools.46999.n3.nabble.com/Preventing-re-evaluation-on-modificatio...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 1 month
Problem with DroolsFlow transaction
by HMandic
I have a problem with transaction manager in drools flow (at least I think
so).
I'm running an EJB3 application in Jboss AS 5.1.0GA with Postgres 8.4.4 as
database. I use one schema for my data and another for drools data. The
application itself is also split in two projects, one for my utility classes
that interact with drools and the other for my application that uses those
utility classes.
I'm using the same datasource and transaction type is JTA.
I have an object that holds a reference to processID from drools flow as one
of its fields. When I invoke my method to create that object (in a stateless
session bean), a transaction is opened and it lasts until the end of said
method. But somewhere inside that method I need to invoke
ksession.startProcess(processName, params) and then I get this:
java.lang.IllegalStateException: Wrong tx on thread: expected
TransactionImple < ac, BasicAction: -3f57ffd6:dfb:4c878d37:7e status:
ActionStatus.ABORTED >, actual null
at org.jboss.aspects.tx.TxPolicy.endTransaction(TxPolicy.java:157)
at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:87)
at
org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:190)
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)
.
.
.
Does that mean that I need to run the drools part in a separate thread?
I'm clueless...
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Problem-with-DroolsFl...
Sent from the Drools - User mailing list archive at Nabble.com.
13 years, 1 month
Using Drools Flow with Multiple Fact Types
by Jason
I'm a relatively new user to Flows, but I have worked with a colleague to
instantiate flows that control a sequence of rule sets being applied to a
set of data in a meaningful order (e.g. I do pruning to limit the set of
facts as a first step, then generate sets of hypotheses, then score the
hypotheses and select the highest-scoring instance as a winner), so I do
have some experience and a baseline working Flow that is successfully
operating.
My next big challenge is to try to use Drools Flow to control which sets of
rules will be applied to which subsets of data - this goes beyond the uses I
have put it to before, which was just to control the single ordering of rule
sets that was then applied to all data.
My question has to do with the syntax of fact constraints used for
controlling flow, and how to control the flow using constraints that reflect
data characteristics when there are many different fact types that will be
going through the Flow. I will use an analogy to the actual problem to make
it a little simpler to describe.
What I want to do is to apply different rules based on the Program that a
particular Customer belongs to. If a customer is part of Program A, then I
want to apply RuleSet A, and if the Customer belongs to Program B then I
want to apply a different set of rules, RuleSet B.
My problem is twofold:
1.) I have not been able to demonstrate constraints working as I expected,
even when I simplified the data flow to its most basic form. The 'debug'
version of the flow that I created has a diverging OR gateway (specifically
OR, not an XOR gateway) with two criteria; the first is always true and
therefore all instances should result in an instance of LogStatementA, and
the second one has a constraint on the UserID associated with the customer
and thereby limits the set that should be exposed to a rule that generates
an instance of LogStatementB: "Customer(userId > 100)" as an example of
something I've tried, where any Customers with a UserID above 100 would then
trigger an instance of both LogStatementA and LogStatementB, while customers
with a UserID <= 100 would only trigger an instance of LogStatementA.
What I find is that if I set the constraint such that at least one Customer
instance in the data should trigger the selection, then ALL of the instances
of Customer in the data end up triggering an instance of LogStatementB (even
those instances that do not individually meet the constraint), while if I
set the constraint such that none of the Customer instances meets it, I get
zero instances of LogStatementB. In both cases, I get an instance of
LogStatementA for each Customer (as expected).
I don't understand why the existence of a single match to the Flow Control
rule (Customer(userId>100)) would trigger all instances of Customers
(including those with UserID's less than 100) to be routed to that path,
while having no matching instances correctly avoids sending any Customers
down this path.
Is there a common type of error that I might have perpetrated that would
cause this? I have tried a variety of combinations of the Type: and
Dialect: settings, though intuitively it seems like Type: Rule and
Dialect:mvel are correct given that I'm formulating the constraint as
"Customer(userId>100)". Also, if I introduce a typo in either the Customer
or userId elements of the rule, I get errors that make it clear the POJO for
this constraint is definitely being correctly imported.
2.) Assuming there is a fix to the underlying issue I'm seeing in #1, I
will want to extend this example so that I am pushing more than just
instances of Customer through my Flow. In particular, the rules that i want
to expose the data to after the diverging gateway represent different
flavors of the same type of logic, so what I want in the end is for all
Customer facts to be sent either one way or the other, and all non-Customer
facts to be sent BOTH ways. This will allow me, for instance, to apply
different thresholds to customers depending on which Program they are part
of.
I first formulated an attempt at the control rule for this as:
Customer(userId>100) or not Customer
with the idea that if the data coming through the flow is an instance of a
Customer, then I want the constraint to be applied to determine if it
proceeds down this flow, but if the data is not an instance of Customer then
I always want it to proceed down the path (e.g. all Account instances, all
RewardThreshold instances, etc.).
Is this a valid way to expect to use Drools Flow? In the examples I've
seen, there is only a single type of object that is going through a flow -
am I breaking the spirit of Drools Flow in trying to get multiple types of
facts flowing through?
Assuming I'm not committing heresy in this basic desire of what I'm trying
to do, is there an example anywhere of what the appropriate syntax for this
kind of constraint would/could be? Any of the variants I have tried (and
believe me, I've tried a bunch) have resulted in parsing errors (often of
the "unmatched then" or "unmatched (" sort when the flow is initially read
in). Can anyone point me to an example of a flow where multiple types of
facts are sent through? In fact, any pointers to examples of the syntax
that has been used within the Constraint Editor Textual Editor field could
help a lot in illustrating how to apply this element of Drools Flow control.
Any help or guidance will be greatly appreciated!
-Jason
--
View this message in context: http://drools.46999.n3.nabble.com/Using-Drools-Flow-with-Multiple-Fact-Ty...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 1 month
Error opening dslr in Eclipse on Mac
by Steven Williams
Hi,
I am running Eclipse Helios on Mac OS X 10.6.7 with the Drools 5.1.1 plugin
and cannot open DSLR files with the error below. This error also occurs if I
create a new Drools project, create a new rule resource and select the Use a
DSL checkbox. DRL files open fine.
Could not open the editor: 1
java.lang.ArrayIndexOutOfBoundsException: 1
at
org.eclipse.swt.custom.StyledTextRenderer.calculateClientArea(StyledTextRenderer.java:230)
at org.eclipse.swt.custom.StyledText.handleResize(StyledText.java:6169)
at org.eclipse.swt.custom.StyledText$7.handleEvent(StyledText.java:5662)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:3783)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1375)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1398)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1379)
at org.eclipse.swt.widgets.Control.resized(Control.java:2944)
at org.eclipse.swt.widgets.Composite.resized(Composite.java:929)
at org.eclipse.swt.widgets.Control.setFrameSize(Control.java:3428)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4975)
at org.eclipse.swt.internal.cocoa.OS.objc_msgSend(Native Method)
at org.eclipse.swt.internal.cocoa.NSView.setFrameSize(NSView.java:259)
at org.eclipse.swt.widgets.Control.setBounds(Control.java:3171)
at org.eclipse.swt.widgets.Control.setSize(Control.java:3668)
at
org.eclipse.jface.text.source.SourceViewer$RulerLayout.getVerticalScrollArrowHeights(SourceViewer.java:200)
at
org.eclipse.jface.text.source.SourceViewer$RulerLayout.layout(SourceViewer.java:157)
at org.eclipse.swt.widgets.Composite.updateLayout(Composite.java:1183)
at org.eclipse.swt.widgets.Composite.layout(Composite.java:703)
at org.eclipse.swt.widgets.Composite.layout(Composite.java:661)
at
org.eclipse.jface.text.source.CompositeRuler.layoutTextViewer(CompositeRuler.java:611)
at
org.eclipse.jface.text.source.CompositeRuler.addDecorator(CompositeRuler.java:565)
at
org.eclipse.jface.text.source.projection.ProjectionViewer.addVerticalRulerColumn(ProjectionViewer.java:1289)
at
org.eclipse.jface.text.source.projection.ProjectionSupport.doEnableProjection(ProjectionSupport.java:310)
at
org.eclipse.jface.text.source.projection.ProjectionSupport$ProjectionListener.projectionEnabled(ProjectionSupport.java:143)
at
org.eclipse.jface.text.source.projection.ProjectionViewer.fireProjectionEnabled(ProjectionViewer.java:489)
at
org.eclipse.jface.text.source.projection.ProjectionViewer.enableProjection(ProjectionViewer.java:537)
at
org.eclipse.jface.text.source.projection.ProjectionViewer.doOperation(ProjectionViewer.java:1441)
at org.drools.eclipse.editors.AbstractRuleEditor.createPartControl(Unknown
Source)
at
org.eclipse.ui.part.MultiPageEditorPart.addPage(MultiPageEditorPart.java:241)
at org.eclipse.ui.forms.editor.FormEditor.addPage(FormEditor.java:325)
at
org.eclipse.ui.part.MultiPageEditorPart.addPage(MultiPageEditorPart.java:211)
at org.eclipse.ui.forms.editor.FormEditor.addPage(FormEditor.java:308)
at org.drools.eclipse.dsl.editor.DSLRuleEditor2.addPages(Unknown Source)
at org.eclipse.ui.forms.editor.FormEditor.createPages(FormEditor.java:138)
at
org.eclipse.ui.part.MultiPageEditorPart.createPartControl(MultiPageEditorPart.java:348)
at
org.eclipse.ui.internal.EditorReference.createPartHelper(EditorReference.java:670)
at
org.eclipse.ui.internal.EditorReference.createPart(EditorReference.java:465)
at
org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:595)
at
org.eclipse.ui.internal.EditorReference.getEditor(EditorReference.java:289)
at
org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched(WorkbenchPage.java:2863)
at
org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:2768)
at org.eclipse.ui.internal.WorkbenchPage.access$11(WorkbenchPage.java:2760)
at org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.java:2711)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2707)
at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2691)
at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2682)
at org.eclipse.ui.ide.IDE.openEditor(IDE.java:651)
at org.eclipse.ui.ide.IDE.openEditor(IDE.java:610)
at org.drools.eclipse.wizard.rule.NewRulePackagePage.finish(Unknown Source)
at org.drools.eclipse.wizard.rule.NewRulePackageWizard.performFinish(Unknown
Source)
at
org.eclipse.jface.wizard.WizardDialog.finishPressed(WizardDialog.java:811)
at
org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:430)
at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:624)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:234)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:3783)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1375)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1398)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1383)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1195)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3629)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3284)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)
at org.eclipse.jface.window.Window.open(Window.java:801)
at
org.eclipse.ui.internal.handlers.WizardHandler$New.executeHandler(WizardHandler.java:254)
at
org.eclipse.ui.internal.handlers.WizardHandler.execute(WizardHandler.java:274)
at
org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:293)
at org.eclipse.core.commands.Command.executeWithChecks(Command.java:476)
at
org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
at
org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:169)
at
org.eclipse.ui.internal.handlers.SlaveHandlerService.executeCommand(SlaveHandlerService.java:241)
at
org.eclipse.ui.internal.actions.CommandAction.runWithEvent(CommandAction.java:157)
at
org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
at
org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
at
org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:3783)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1375)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1398)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1383)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1195)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3629)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3284)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2640)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)
at
org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at
org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
at
org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
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.eclipse.equinox.launcher.Main.invokeFramework(Main.java:620)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:575)
at org.eclipse.equinox.launcher.Main.run(Main.java:1408)
thanks
Steve
13 years, 1 month
Help with troubleshooting rules/Drools
by Robert Crawford
Any advice on how to troubleshoot problems? I have a fairly simple set of
rules (a couple dozen), but keep having problems with fatal exceptions. The
most recent was:
org.drools.RuntimeDroolsException: Unexpected exception executing action
org.drools.reteoo.PropagationQueuingNode$PropagateAction@1e60aa7
at
org.drools.common.AbstractWorkingMemory.executeQueuedActions(AbstractWorkingMemory.java:977)
at
org.drools.common.DefaultAgenda.fireUntilHalt(DefaultAgenda.java:1231)
at
org.drools.common.AbstractWorkingMemory.fireUntilHalt(AbstractWorkingMemory.java:753)
at
org.drools.common.AbstractWorkingMemory.fireUntilHalt(AbstractWorkingMemory.java:729)
at
org.drools.impl.StatefulKnowledgeSessionImpl.fireUntilHalt(StatefulKnowledgeSessionImpl.java:234)
at
com.kroger.tempmonitor.app.service.RuleService$1.run(RuleService.java:214)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.util.NoSuchElementException
at java.util.LinkedList.remove(LinkedList.java:788)
at java.util.LinkedList.removeFirst(LinkedList.java:134)
at
org.drools.common.PropagationContextImpl.evaluateActionQueue(PropagationContextImpl.java:264)
at
org.drools.reteoo.PropagationQueuingNode$AssertAction.execute(PropagationQueuingNode.java:357)
at
org.drools.reteoo.PropagationQueuingNode.propagateActions(PropagationQueuingNode.java:238)
at
org.drools.reteoo.PropagationQueuingNode$PropagateAction.execute(PropagationQueuingNode.java:502)
at
org.drools.common.AbstractWorkingMemory.executeQueuedActions(AbstractWorkingMemory.java:975)
... 6 more
No mention of a rule name, so where do I begin?
My architecture is simple: one thread ran fireUntilHalt(), other (multiple)
threads inserting objects. Should I synchronize on the session so only one
thread is inserting at a time?
There's one rule that triggers a large number of inserts, and it used to
give me problems, but I've moved those inserts into Commands and those
problems seem to have gone away.
Any advice would be welcome, no matter how basic you think it is! Thanks!
--
View this message in context: http://drools.46999.n3.nabble.com/Help-with-troubleshooting-rules-Drools-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 1 month
Guvnor custom form not working for DSL sentences
by GPatel@tsys.com
Hi
Is the guvnor custom form not meant for use with fact fields appearing in
dsl sentences? It works fine with guided editor, not with dsl though.
Using 5.3.CR1
Thanks
G. Patel
-----------------------------------------
The information contained in this communication (including any
attachments hereto) is confidential and is intended solely for the
personal and confidential use of the individual or entity to whom
it is addressed. If the reader of this message is not the intended
recipient or an agent responsible for delivering it to the intended
recipient, you are hereby notified that you have received this
communication in error and that any review, dissemination, copying,
or unauthorized use of this information, or the taking of any
action in reliance on the contents of this information is strictly
prohibited. If you have received this communication in error,
please notify us immediately by e-mail, and delete the original
message. Thank you
13 years, 1 month
Online 5.3.0 javadocs
by Martin A
Hello,
I'm looking for the online 5.3.0 javadocs, but can't find it... Would you
point me to a reference?
Thanks,
Martin
13 years, 1 month
rule fires several times
by elsdestickere
Hi,
The Expert documentation says " a rule may fire once or several times", but
I don't understand why a rule sould fire several times if the objects state
does not change?
I have an example of a Customer object inserted in the Working Memory, with
2 rules that should fire, but the last rule fires twice.
Can someone explain?
rule "isAdult"
when
k : Customer( age(date)>=18, adult==false );
then
modify( k ) { setAdult(true) };
System.out.println( "Drools "+drools.getRule().getName()+": "+
k.getAdult() );
end
rule "WM"
when
k : Customer( ) ;
then
System.out.println( "Drools "+drools.getRule().getName()+": "
+k.getName());
end
...
Customer bert = new Customer ();
bert.setName("Bert");
bert.setDate(30);
ksession.insert(bert);
ksession.fireAllRules();
...
Output:
Drools WM: Bert
Drools isAdult: true
Drools WM: Bert
Br,
Els Destickere
--
View this message in context: http://drools.46999.n3.nabble.com/rule-fires-several-times-tp3466250p3466...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 1 month