Creating template column in guvnor for attribute value?
by dunnlow
I'm using Guvnor 5.4
I find myself sometimes wanting to use templates to map a string to a
metadata value or timer. For example, based upon a name, set a value for
the timeout. As far as I can tell however, the only way to create a
template column in guvnor is to include the column identifier in the LHS.
For example, I have a basic rule template that checks a name (there is only
a "name" column in the template matrix). Then, I click on options, add a
timer and give it a value of "@{timeout}" I get an error - the timeout
column does not exist in the template. However, if I write a dummy
expression on the LHS like "foo" not matches timeout, the timeout column is
created and everything is great once I set the value. If I delete the
predicate that uses timeout, I get an error again for the timer attribute.
This gets really ugly because I end up having (seemingly) useless
predicates. Is there a clean way to support this functionality?
Thanks,
-J
--
View this message in context: http://drools.46999.n3.nabble.com/Creating-template-column-in-guvnor-for-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years
Drools 6 - approximate release date?
by Michal Bali
Hi guys,
anybody knows when is Drools version 6 going to be released? In a year?
Year and a half? More?
Thank you in advance.
Best regards,
Michal
14 years
Events do not get removed automatically
by Winfried Umbrath
Hi guys,
the drools fusion documentation states that
"One of the benefits of running the engine in STREAM mode is that the
engine can detect when an event can no longer match any rule due to its
temporal constraints. When that happens, the engine can safely retract
the event from the session without side effects and release any
resources used by that event."
I have a hard time understanding why my events do not get removed. In
the following example I have following rules running in stream mode:
----------------------------------------------------------------------------------------------------------------------------
package rules
import java.util.logging.Logger
declare GenericEvent
@role(event)
playerIndex : long
eventName : String
card : String
chosenSuit : String
end
declare Table
currentPlayerIndex : long
topCard : String
end
rule "new table"
when
not Table()
then
insert(new Table(0,"a"));
end
rule "discardChoosing"
when
$event : GenericEvent(eventName=="discardCard", $playerIndex :
playerIndex, card.equals("c")) from entry-point "my stream"
$table : Table(currentPlayerIndex==$playerIndex, !topCard.equals("c"))
then
Logger.getLogger("####").info("discardChoosing FIRED");
modify($table) {setTopCard("c")};
end
rule "choosingSuit"
no-loop
when
$event : GenericEvent(eventName=="choosingSuit", $playerIndex :
playerIndex, $chosenSuit : chosenSuit) from entry-point "my stream"
$table : Table(currentPlayerIndex==$playerIndex)
$discardCardEvent : GenericEvent(eventName=="discardCard",
playerIndex==$playerIndex, card.equals("c")) from entry-point "my stream"
then
Logger.getLogger("####").info("choosingSuit FIRED");
modify($table)
{setCurrentPlayerIndex($table.getCurrentPlayerIndex() + 1)};
end
rule "previousPlayer"
when
$event : GenericEvent(eventName=="previousPlayer") from entry-point
"my stream"
$table : Table()
then
Logger.getLogger("####").info("previousPlayer FIRED");
modify($table)
{setCurrentPlayerIndex($table.getCurrentPlayerIndex() - 1)};
end
----------------------------------------------------------------------------------------------------------------------------
I would expect after inserting "discardCard" followed by "choosingSuit"
event, both should be retracted as their conditions do not evaluate to
true anymore. But even after sleeping a couple of seconds, the rule
"choosingSuit" fires again, which means to me the events are still in
working memory. Here is the log output:
inserting GenericEvent( playerIndex=0, eventName=discardCard, card=c,
chosenSuit=null )
INFO: discardChoosing FIRED
INFO: choosingSuit FIRED
inserting GenericEvent( playerIndex=0, eventName=choosingSuit,
card=null, chosenSuit=HEARTS )
Sleeping 9 seconds...
Sleeping done. Printing facts:
Fact handle: [fact 0:2:1690464956:1690464956:5:DEFAULT:Table(
currentPlayerIndex=1, topCard=c )]
inserting GenericEvent( playerIndex=0, eventName=previousPlayer,
card=null, chosenSuit=null )
INFO: previousPlayer FIRED
INFO: choosingSuit FIRED
INFO: previousPlayer FIRED
INFO: choosingSuit FIRED
INFO: previousPlayer FIRED
INFO: choosingSuit FIRED
INFO: previousPlayer FIRED
INFO: choosingSuit FIRED
INFO: previousPlayer FIRED
...
I'm running Drools 5.4 and inserting/executing in this way:
List cmds = new ArrayList();
cmds.add(CommandFactory.newInsert(discard, "event", false, "my stream"));
cmds.add(CommandFactory.newFireAllRules(20));
System.out.println("inserting " + discard);
ksession.execute(CommandFactory.newBatchExecution(cmds));
Any help is highly appreciated.
14 years
MVEL version
by paco
Hello
The rules have been written with guvnor 5.0
I have imported it on guvnor 5.3.0
However I met some syntax errors due to the new version of MVEL.
I can not find new versions of MVEL related to guvnor 5.3.0
Can someone tell me how I can get to know the version of MVEL of guvnor
5.3.0 ?
I’m using guvnor 5.3.0 and java 1.6.0.24
Thank you
--
View this message in context: http://drools.46999.n3.nabble.com/MVEL-version-tp4019113.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years
Drools 5.4 - Can't catch Exception
by gboro54
So I keep getting the exceptions below. I have surrounded the fireAllRules
with a try catch throwable block to try and debug this but I never seem to
be able to catch it. This only happens in the first couple 100 invocations
of the fireAllRules then never happens again(sometimes it never happens at
all). Is there a way to handle this exception or prevent it from happening?
I am assuming that this is occurring do to an activation being evaluated
after the OrderSideContext is retracted from working memory. Anyone else run
into a similar issue?
TIA
-Mike
07:48:35,377 ERROR [stderr] (Thread-118) Exception in thread "Thread-118"
java.lang.RuntimeException: unable to invoke method:
com.billing.domain.context.OrderSideContext.getPrimarySide: target of method
is null
07:48:35,377 ERROR [stderr] (Thread-118) at
org.mvel2.optimizers.impl.refl.nodes.GetterAccessor.getValue(GetterAccessor.java:66)
07:48:35,377 ERROR [stderr] (Thread-118) at
org.mvel2.optimizers.impl.refl.nodes.VariableAccessor.getValue(VariableAccessor.java:37)
07:48:35,378 ERROR [stderr] (Thread-118) at
org.mvel2.ast.ASTNode.getReducedValueAccelerated(ASTNode.java:108)
07:48:35,378 ERROR [stderr] (Thread-118) at
org.mvel2.ast.BinaryOperation.getReducedValueAccelerated(BinaryOperation.java:107)
07:48:35,378 ERROR [stderr] (Thread-118) at
org.mvel2.ast.Or.getReducedValueAccelerated(Or.java:34)
07:48:35,378 ERROR [stderr] (Thread-118) at
org.mvel2.compiler.ExecutableAccessor.getValue(ExecutableAccessor.java:38)
07:48:35,378 ERROR [stderr] (Thread-118) at
org.mvel2.ast.Substatement.getReducedValueAccelerated(Substatement.java:44)
07:48:35,378 ERROR [stderr] (Thread-118) at
org.mvel2.ast.And.getReducedValueAccelerated(And.java:34)
07:48:35,378 ERROR [stderr] (Thread-118) at
org.mvel2.MVELRuntime.execute(MVELRuntime.java:85)
07:48:35,379 ERROR [stderr] (Thread-118) at
org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:123)
07:48:35,379 ERROR [stderr] (Thread-118) at
org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:116)
07:48:35,379 ERROR [stderr] (Thread-118) at
org.mvel2.MVEL.executeExpression(MVEL.java:930)
07:48:35,379 ERROR [stderr] (Thread-118) at
org.drools.rule.constraint.MvelConditionEvaluator.evaluate(MvelConditionEvaluator.java:70)
07:48:35,379 ERROR [stderr] (Thread-118) at
org.drools.rule.constraint.MvelConditionEvaluator.ensureBranchEvaluation(MvelConditionEvaluator.java:113)
07:48:35,379 ERROR [stderr] (Thread-118) at
org.drools.rule.constraint.MvelConditionEvaluator.ensureCompleteEvaluation(MvelConditionEvaluator.java:106)
07:48:35,380 ERROR [stderr] (Thread-118) at
org.drools.rule.constraint.MvelConditionEvaluator.ensureCompleteEvaluation(MvelConditionEvaluator.java:90)
07:48:35,380 ERROR [stderr] (Thread-118) at
org.drools.rule.constraint.MvelConditionEvaluator.getAnalyzedCondition(MvelConditionEvaluator.java:82)
07:48:35,380 ERROR [stderr] (Thread-118) at
org.drools.rule.constraint.MvelConstraint.executeJitting(MvelConstraint.java:214)
07:48:35,380 ERROR [stderr] (Thread-118) at
org.drools.rule.constraint.MvelConstraint.access$000(MvelConstraint.java:41)
07:48:35,380 ERROR [stderr] (Thread-118) at
org.drools.rule.constraint.MvelConstraint$1.run(MvelConstraint.java:201)
07:48:35,381 ERROR [stderr] (Thread-118) at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
07:48:35,381 ERROR [stderr] (Thread-118) at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
07:48:35,381 ERROR [stderr] (Thread-118) at
java.lang.Thread.run(Thread.java:662)
07:48:35,381 ERROR [stderr] (Thread-118) Caused by:
java.lang.NullPointerException
07:48:35,381 ERROR [stderr] (Thread-118) at
sun.reflect.GeneratedMethodAccessor163.invoke(Unknown Source)
07:48:35,381 ERROR [stderr] (Thread-118) at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
07:48:35,382 ERROR [stderr] (Thread-118) at
java.lang.reflect.Method.invoke(Method.java:597)
07:48:35,382 ERROR [stderr] (Thread-118) at
org.mvel2.optimizers.impl.refl.nodes.GetterAccessor.getValue(GetterAccessor.java:40)
07:48:35,382 ERROR [stderr] (Thread-118) ... 22 more
07:48:35,856 ERROR [stderr] (Thread-132) Exception in thread "Thread-132"
java.lang.RuntimeException: unable to invoke method:
com.billing.domain.context.OrderSideContext.getPrimarySide: target of method
is null
07:48:35,856 ERROR [stderr] (Thread-132) at
org.mvel2.optimizers.impl.refl.nodes.GetterAccessor.getValue(GetterAccessor.java:66)
07:48:35,857 ERROR [stderr] (Thread-132) at
org.mvel2.optimizers.impl.refl.nodes.VariableAccessor.getValue(VariableAccessor.java:37)
07:48:35,857 ERROR [stderr] (Thread-132) at
org.mvel2.ast.ASTNode.getReducedValueAccelerated(ASTNode.java:108)
07:48:35,857 ERROR [stderr] (Thread-132) at
org.mvel2.ast.BinaryOperation.getReducedValueAccelerated(BinaryOperation.java:107)
07:48:35,857 ERROR [stderr] (Thread-132) at
org.mvel2.ast.And.getReducedValueAccelerated(And.java:34)
07:48:35,857 ERROR [stderr] (Thread-132) at
org.mvel2.MVELRuntime.execute(MVELRuntime.java:85)
07:48:35,857 ERROR [stderr] (Thread-132) at
org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:123)
07:48:35,858 ERROR [stderr] (Thread-132) at
org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:116)
07:48:35,858 ERROR [stderr] (Thread-132) at
org.mvel2.MVEL.executeExpression(MVEL.java:930)
07:48:35,858 ERROR [stderr] (Thread-132) at
org.drools.rule.constraint.MvelConditionEvaluator.evaluate(MvelConditionEvaluator.java:70)
07:48:35,858 ERROR [stderr] (Thread-132) at
org.drools.rule.constraint.MvelConditionEvaluator.ensureBranchEvaluation(MvelConditionEvaluator.java:113)
07:48:35,858 ERROR [stderr] (Thread-132) at
org.drools.rule.constraint.MvelConditionEvaluator.ensureCompleteEvaluation(MvelConditionEvaluator.java:106)
07:48:35,859 ERROR [stderr] (Thread-132) at
org.drools.rule.constraint.MvelConditionEvaluator.ensureCompleteEvaluation(MvelConditionEvaluator.java:90)
07:48:35,859 ERROR [stderr] (Thread-132) at
org.drools.rule.constraint.MvelConditionEvaluator.getAnalyzedCondition(MvelConditionEvaluator.java:82)
07:48:35,859 ERROR [stderr] (Thread-132) at
org.drools.rule.constraint.MvelConstraint.executeJitting(MvelConstraint.java:214)
07:48:35,859 ERROR [stderr] (Thread-132) at
org.drools.rule.constraint.MvelConstraint.access$000(MvelConstraint.java:41)
07:48:35,859 ERROR [stderr] (Thread-132) at
org.drools.rule.constraint.MvelConstraint$1.run(MvelConstraint.java:201)
07:48:35,859 ERROR [stderr] (Thread-132) at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
07:48:35,860 ERROR [stderr] (Thread-132) at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
07:48:35,860 ERROR [stderr] (Thread-132) at
java.lang.Thread.run(Thread.java:662)
07:48:35,860 ERROR [stderr] (Thread-132) Caused by:
java.lang.NullPointerException
07:48:35,860 ERROR [stderr] (Thread-132) at
sun.reflect.GeneratedMethodAccessor163.invoke(Unknown Source)
07:48:35,860 ERROR [stderr] (Thread-132) at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
07:48:35,860 ERROR [stderr] (Thread-132) at
java.lang.reflect.Method.invoke(Method.java:597)
07:48:35,861 ERROR [stderr] (Thread-132) at
org.mvel2.optimizers.impl.refl.nodes.GetterAccessor.getValue(GetterAccessor.java:40)
07:48:35,861 ERROR [stderr] (Thread-132) ... 19 more
07:48:36,914 ERROR [stderr] (Thread-96) Exception in thread "Thread-96"
[Error: null pointer or function not found: cSide]
07:48:36,914 ERROR [stderr] (Thread-96) [Near : {... == "A" ||
liquidityIndicator != "R" && matchId < $tsc.cSide.matchId ....}]
07:48:36,914 ERROR [stderr] (Thread-96)
^
07:48:36,915 ERROR [stderr] (Thread-96) [Line: 1, Column: 69]
07:48:36,915 ERROR [stderr] (Thread-96) at
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:1022)
07:48:36,915 ERROR [stderr] (Thread-96) at
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:987)
07:48:36,915 ERROR [stderr] (Thread-96) at
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getBeanProperty(ReflectiveAccessorOptimizer.java:677)
07:48:36,915 ERROR [stderr] (Thread-96) at
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getBeanPropertyAO(ReflectiveAccessorOptimizer.java:472)
07:48:36,916 ERROR [stderr] (Thread-96) at
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:374)
07:48:36,916 ERROR [stderr] (Thread-96) at
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:143)
07:48:36,916 ERROR [stderr] (Thread-96) at
org.mvel2.ast.ASTNode.optimize(ASTNode.java:159)
07:48:36,916 ERROR [stderr] (Thread-96) at
org.mvel2.ast.ASTNode.getReducedValueAccelerated(ASTNode.java:115)
07:48:36,916 ERROR [stderr] (Thread-96) at
org.mvel2.ast.BinaryOperation.getReducedValueAccelerated(BinaryOperation.java:107)
07:48:36,916 ERROR [stderr] (Thread-96) at
org.mvel2.ast.And.getReducedValueAccelerated(And.java:34)
07:48:36,917 ERROR [stderr] (Thread-96) at
org.mvel2.MVELRuntime.execute(MVELRuntime.java:85)
07:48:36,917 ERROR [stderr] (Thread-96) at
org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:123)
07:48:36,917 ERROR [stderr] (Thread-96) at
org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:116)
07:48:36,917 ERROR [stderr] (Thread-96) at
org.mvel2.MVEL.executeExpression(MVEL.java:930)
07:48:36,917 ERROR [stderr] (Thread-96) at
org.drools.rule.constraint.MvelConditionEvaluator.evaluate(MvelConditionEvaluator.java:70)
07:48:36,917 ERROR [stderr] (Thread-96) at
org.drools.rule.constraint.MvelConditionEvaluator.ensureBranchEvaluation(MvelConditionEvaluator.java:113)
07:48:36,918 ERROR [stderr] (Thread-96) at
org.drools.rule.constraint.MvelConditionEvaluator.ensureCompleteEvaluation(MvelConditionEvaluator.java:106)
07:48:36,918 ERROR [stderr] (Thread-96) at
org.drools.rule.constraint.MvelConditionEvaluator.ensureCompleteEvaluation(MvelConditionEvaluator.java:90)
07:48:36,918 ERROR [stderr] (Thread-96) at
org.drools.rule.constraint.MvelConditionEvaluator.getAnalyzedCondition(MvelConditionEvaluator.java:82)
07:48:36,918 ERROR [stderr] (Thread-96) at
org.drools.rule.constraint.MvelConstraint.executeJitting(MvelConstraint.java:214)
07:48:36,918 ERROR [stderr] (Thread-96) at
org.drools.rule.constraint.MvelConstraint.access$000(MvelConstraint.java:41)
07:48:36,919 ERROR [stderr] (Thread-96) at
org.drools.rule.constraint.MvelConstraint$1.run(MvelConstraint.java:201)
07:48:36,919 ERROR [stderr] (Thread-96) at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
07:48:36,919 ERROR [stderr] (Thread-96) at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
07:48:36,919 ERROR [stderr] (Thread-96) at
java.lang.Thread.run(Thread.java:662)
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-5-4-Can-t-catch-Exception-tp4018...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years
questions about conflict resolution
by Frank Wilson
Hi all,
I can't seem to get a clear answer from the manual. In understand that if rules are at the same priority their execution order (the conflict resolution) will be arbitrary. What I am not sure of is if the order is the same for every run on all machines. Could somebody clarify this for me?
Thanks,
Frank
14 years
Re: [rules-users] modifying the problem facts while running the solver - Drools Planner
by ge0ffrey
spinjala wrote
>
> I am new to Drools planner. I have one issue and wanted to understand how
> to resolve it best.
>
> I am trying to use planner to optimize the scheduling of work orders to
> resources. I have certain resources that need to be assigned to a work
> order in a way that maximizes the utilization of the resource. But I have
> a condition where once a resource is scheduled for a workorder, he/she
> shouldn't be scheduled for any other work order again during the same day.
> How do we manage this condition? do we add it as a constraint in the
> drools rule file so that scoring can handle it or do we write a custom
> solver phase to check if a solution has this resource assigned to a WO,
> then skip the resource and proceed with further solution. Please help.
>
See nurseRosteringScoreRules.drl:
// a nurse can only work one shift per day, i.e. no two shift can be
assigned to the same nurse on a day.
rule "oneShiftPerDay"
when
$leftAssignment : ShiftAssignment($leftId : id, $employee :
employee, $shiftDate : shiftDate)
$rightAssignment : ShiftAssignment(employee == $employee, shiftDate
== $shiftDate, id > $leftId)
then
insertLogical(new IntConstraintOccurrence("oneShiftPerDay",
ConstraintType.NEGATIVE_HARD,
1,
$leftAssignment, $rightAssignment));
end
--
View this message in context: http://drools.46999.n3.nabble.com/modifying-the-problem-facts-while-runni...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years
Connecting to repository using JMS
by Anton Hughes
Hi
I would like to connect to guvnor / repository using jms.
I am currently also using camel.
Is there any documentation, samples, articles on this?
Thanks and regards,
Anton
14 years