[rules-users] Killing a session

Wolfgang Laun wolfgang.laun at gmail.com
Tue May 15 15:55:47 EDT 2012


A very low salience rule depending on nothing and calling halt will stop
the run:

rule Exit
salience -999999999
when
then
    drools.halt();
end

-W

On 15 May 2012 21:46, mike <mikemps at gmail.com> wrote:

> Well I got this wrong sorry. Yes I can stop a session if I start it with
> fireUntilHalt() but it never stops. I need it to finish by itself too.
>
> Thank you
> Mike
>
>
> On Tue, May 15, 2012 at 11:06 AM, mike <mikemps at gmail.com> wrote:
>
>> wow that worked like a charm!!! thank you very much  Wolfgang, I owe u a
>> beer or something :)
>>
>> Cheers
>> Mike
>>
>>
>> On Tue, May 15, 2012 at 11:01 AM, mike <mikemps at gmail.com> wrote:
>>
>>> Awesome I'll try that :)
>>>
>>> We got business ppl writing rules ... Those rules are going on infinite
>>> loops quite often ...  Frankly I am not excited about killing the session,
>>> for me it's just a business request that I am trying to implement
>>>
>>> Thank you very much Wolfgang
>>>
>>> Cheers
>>> Mike
>>>
>>>
>>> On Tue, May 15, 2012 at 10:53 AM, Wolfgang Laun <wolfgang.laun at gmail.com
>>> > wrote:
>>>
>>>> You are confusing jBPM processes and Java threads.
>>>>
>>>> You can interrupt the thread SessionThread, but that's not reliable
>>>> (if IE is handled, for instance),
>>>>
>>>> Best would be to call fireUntilHalt() and call the session's halt
>>>> method.
>>>>
>>>> But why would you want to do this sort of weird thing?
>>>>
>>>> -W
>>>>
>>>>
>>>> On 15/05/2012, mike <mikemps at gmail.com> wrote:
>>>> > Hi there,
>>>> >
>>>> > Is there any way to kill a running session?
>>>> >
>>>> > I've been trying with StatefulKnowledgeSession.abortProcessInstance
>>>> but i
>>>> > can't get it working.
>>>> >
>>>> > For instance .. I got this drl
>>>> >
>>>> > rule "infinite loop"
>>>> >     when x : Integer()
>>>> >     then
>>>> >          System.out.println(x);
>>>> >          Thread.sleep(100);
>>>> >           insert(x + 1);
>>>> > end
>>>> >
>>>> > n' this Thread
>>>> >
>>>> > public class SessionThread implements Runnable {
>>>> >  private StatefulKnowledgeSession session;
>>>> > public SessionThread(StatefulKnowledgeSession session) { this.session
>>>> =
>>>> > session; }
>>>> >          public void run() { session.fireAllRules(); }
>>>> > }
>>>> >
>>>> > then i create a session with the drl n' do something like ...
>>>> >
>>>> > session.insert(42);
>>>> > Thread thread = new Thread(new SessionThread(session));
>>>> > thread.start();
>>>> >                 Thread.sleep(1000);
>>>> > session.abortProcessInstance(thread.getId());
>>>> >
>>>> > I've tried diff processInstanceIds and session.getProcessInstances()
>>>> but
>>>> > nothing seems to stop the running session
>>>> >
>>>> > Thank you
>>>> > Mike
>>>> >
>>>> _______________________________________________
>>>> rules-users mailing list
>>>> rules-users at lists.jboss.org
>>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>>
>>>
>>>
>>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20120515/99f48df9/attachment.html 


More information about the rules-users mailing list