Hi Kris! Thanks for your reply!
Ok, I can retrieve the correct timer Ids now using getID().
But now I'm running into an exception when I try to cancel the timer nodes.
I cannot use
"drools.getWorkingMemory().getTimerManager().getTimerService().shutdown();",
because
The shutdown method closes the knowledgeSession.
Maybe I should mention what I am trying to do: I have several processes
running. Each process has severel subflows which have, in turn, timer nodes
so that they are periodically triggered. The subflows are interacting with
databases, so I want to ensure a secure shutdown (event driven). Therefore
it is necessary to cancel the timers, so that there is no new invocation of
the subflows. On the other hand the subflows have to finish their work, so
using Timerservice.shutdown() is not possible!
When I try to cancel the timers in the following way (action node
(Drools5.1)):
Collection<TimerInstance> coll =
drools.getWorkingMemory().getTimerManager().getTimers();
for(TimerInstance ti : coll)
{
drools.getWorkingMemory().getTimerManager().cancelTimer(ti.getId());
}
The following exception occurs:
Exception in thread "Thread-1" java.lang.RuntimeException: unable to execute
Action
at
org.drools.workflow.instance.node.ActionNodeInstance.internalTrigger(ActionN
odeInstance.java:56)
at
org.drools.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.
java:112)
at
org.drools.workflow.instance.impl.NodeInstanceImpl.triggerConnection(NodeIns
tanceImpl.java:148)
at
org.drools.workflow.instance.impl.NodeInstanceImpl.triggerCompleted(NodeInst
anceImpl.java:135)
at
org.drools.workflow.instance.node.EventNodeInstance.triggerCompleted(EventNo
deInstance.java:70)
at
org.drools.workflow.instance.node.EventNodeInstance.internalTrigger(EventNod
eInstance.java:62)
at
org.drools.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.
java:112)
at
org.drools.workflow.instance.node.EventNodeInstance.signalEvent(EventNodeIns
tance.java:50)
at
org.drools.workflow.instance.impl.WorkflowProcessInstanceImpl.signalEvent(Wo
rkflowProcessInstanceImpl.java:272)
at
org.drools.process.instance.event.DefaultSignalManager.signalEvent(DefaultSi
gnalManager.java:58)
at
org.drools.impl.StatefulKnowledgeSessionImpl.signalEvent(StatefulKnowledgeSe
ssionImpl.java:281)
at test.Shutdown.run(Shutdown.java:46)
Caused by: java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.nextEntry(HashMap.java:787)
at java.util.HashMap$ValueIterator.next(HashMap.java:817)
at
com.sample.Process_com_sample_0.action2(Process_com_sample_0.java:28)
at
com.sample.Process_com_sample_0Action2Invoker.execute(Process_com_sample_0Ac
tion2Invoker.java:20)
at
org.drools.workflow.instance.node.ActionNodeInstance.internalTrigger(ActionN
odeInstance.java:54)
... 11 more
-----Ursprüngliche Nachricht-----
Von: Kris Verlaenen [mailto:kris.verlaenen@cs.kuleuven.be]
Gesendet: Dienstag, 13. Oktober 2009 04:20
An: Rules Users List; tom238(a)gmx.at
Cc: rules-users(a)lists.jboss.org
Betreff: Re: [rules-users] cannot retrieve timerId from timerInstance - Bug?
You probably need to use the timer instance id, not the timer id (as
this one is only used to differentiate between timers if you have more
than one timer defined on the same node and you want to link different
actions to each of these timers). So could it be as simple as using
ti.getId() instead of ti.getTimerId() ?
Kris
Quoting tom238(a)gmx.at:
Hi there!
I'm using Drools 5.1.SNAPSHOT.
I want to disable some timer nodes in my ruleflow, so that they will
not trigger anymore. therefore I tried the following code:
Collection<TimerInstance> tcoll =
drools.getWorkingMemory().getTimerManager().getTimers();
for (TimerInstance ti : tcoll)
{
drools.getWorkingMemory().getTimerManager().cancelTimer(ti.getTimerId());
}
OK, so far so good. The code above doesn't work, because
ti.getTimerId() always returns 0. Anyone an idea why this value is 0?
As I've seen in the sources this field is set to an value > 0. this
value is then incremented when you add another timerinstance.
Thanks in advance! hope anyone can help.
tom
--
Jetzt kostenlos herunterladen: Internet Explorer 8 und Mozilla
Firefox 3.5 -
sicherer, schneller und einfacher!
http://portal.gmx.net/de/go/chbrowser
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
Disclaimer:
http://www.kuleuven.be/cwis/email_disclaimer.htm