Jim Beam [https://community.jboss.org/people/jamesbeam] created the discussion

"Waiting for events to occur in a flow?"

To view the discussion, visit: https://community.jboss.org/message/762276#762276

--------------------------------------------------------------
I'm a flow noob (...obviously) using 5.3.

I have a few examples working and am trying to integrate some rules.  I think I 
have a fundamental misunderstanding of rule tasks (maybe flow).   Basically, I 
want to have a more complicated process and I want to only advance to the next 
node when a certain set of conditions are met.  

To set up a simple test, I have a flow, *start node->rule task->script task 
(writes "Done")-> end node*.  I don't want to get to the script task until the 
process receives a message with text='hi' or text='yo'.  I set up the following 
ruleflow group (I have a Message and MessageB class):

  rule "waitforit rule"
       ruleflow-group "waitforMessage"
       dialect "mvel"
  when
      not ($m : Message())
  then
      System.out.println("no message yet");
  end;

  rule "dotone"
       ruleflow-group "waitforMessage"
       dialect "mvel"
  when
      $m : Message(text=='hi' || text=='yo')
  then
      System.out.println("got message:"+$m.text);
  end;

I tried:

1) I start the process and insert a MessageB object (i see hibernate update the 
session).  I expected the first rule to fire, but it does not.  Then I insert a 
Message object and the process/app just exits (WITHOUT) giving me the "Done" 
message (i have a thread.sleep after the insert - and no dispose).

2) So, I start the process and do a fireallrules, wait 10 seconds then insert a 
Message object.  But, as soon as I fireallrules, I get the "no message yet" 
message AND the "Done" message.  Nothing happens for 10 seconds and then the 
process ends.

So, I have just one question....in 6 parts:

    a) in #1, why doesn't the first rule fire?  
    b)   and Why/How does the process exit without a "Done" message?  (I don't 
dispose of the ksession in my code)
    c) in #2, why does the fireallrules immediatly trigger the "Done" message?
    d) as I read it in the documentation, the rule task should keep the process 
from advancing until all of the rules are no longer active.  However, I thought 
the first rule would ensure that the group was active until a Message arives.  
Is that wrong?
    e) what is the right way to do this sort of thing?
    f)  Can someone clue me into what I am doing wrong?  Am I thinking about 
this in the wrong way? 

Thanks very much for your thoughts/comments.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/762276#762276]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]

_______________________________________________
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to