1 of 1 people found this helpful
Can you see that Rule#2 is invoked - I mean process enters the node? You can verify that, for example by enabling console logger for the session.
Would be good if you provide sample bpmn file and code that you use to execute it.
Can you please share an example where EventListener Methods are used.
Thank you for your reply! Yes, I can see that the rule node is invoked, i.e. process is entering the node, but does not execute the rule assigned to it. The code is rather basic. The rules are doing nothing, but just logging a debug info into the log file. The process is invoked from another rule which in its turn is invoked by fileAllRules() against the session from the MQ event handler. Nothing fancy.
I got up this morning and saw at least two posts after mine with similar problems. One of them is from Guo-Guang Chiou.
Now it is obvious to me (yes, just now as I’m a complete novice in Drools/JBPM area) that the rule is not triggered as there is nothing active in the working memory and that the fireAllRules() should somehow be called. I need to do something to make it working, e.g. use some event listeners as it has been suggested in another replies. My question is, why it is not done automatically when Human Task is completed? Is there an event something like afterTaskComplete() so that I could trap it and fire my rules from there?
Vlad, rules must be activated before they can be executed. Activation happens when facts are inserted/updated/retracted into the session. Maybe your case is that nothing happens before the Rule#2 is entered?
You could give a try with a onExit script for you human task node that will make any modification to the session, for instance insert a fact.
<extensionElements> <tns:onExit-script scriptFormat="http://www.java.com/java"> <script>kcontext.getKnowledgeRuntime().insert(kcontext.getProcessInstance());</script> </tns:onExit-script> </extensionElements>
That should activate agenda and when process enters rule task it should have rules ready (of course if the rules condition will be satisfied). I am not a big rules expert so ...
As for the listener, take a look at: org.drools.event.AgendaEventListener an example usage of it can be found here, to trigger rules execution (of ruleflow-group) as soon as they activated.
Hi Maciej ,
I want to use a Business Rule Task after a start node and I want to route my flow to different nodes based on the conditiones evaluated in the drool file of the rule task, But as per the documentation the Business Rule Task can have only one incoming and one outcoming connection, I want to know how it can be done.
Also, Please educate me on the EventListener methods, such as beforeNodeLeft, beforeNodeTriggered etc.
Please provide an example wherein we are using the EventListener methods. and Routing condition based on the rule file evaluation. Also when i use the ksession.fireAllRules method, all rules are getting fired, so i want to know is there any alternate solution to fire rules without explicitly mentioning ksession.fireAllRules method.
I have wasted so much time trying to resolve the same problem. I researched all the measures people are exposing in this forum to solve the problem but nothing seems to work. What I have learnt is that firstly you have to launch the method fireAllRules() in order to activate all the rule tasks associated (it makes an association between ruleflow-group (inside of .drl file) and Rule Task ) but, after the Human Task, everything seems to change . The sequencial flow of our process is suspended, appearing a period where nothing happens. I don´t understand what is happening there but the log console shows that the ruleflow group is activated but the action defined in the .drl file is never launched:
BEFORE RULEFLOW GROUP ACTIVATED group:rule[size=1]
AFTER RULEFLOW GROUP ACTIVATED group:rule[size=1]
AFTER PROCESS NODE TRIGGERED node:Rule[id=4] process:Rule1[id=com.sample.bpmn]
I have been researching through three work lines:
-> With a new thread and the fireUntilHalt(). Method recommended in: https://community.jboss.org/thread/167602
-> With the class AgendaEventListener. Method recommended in: https://community.jboss.org/message/627166#627166
-> And now I´m trying to analyze Maciej´s method with "
Any help will be useful
Well, adding the Agenda Event Listener with fireAllRules() from within the afterRuleFlowGroupActivated() seems to be doing the trick – I have solved the problem with the Rule Item not being executed after the Human Task. From inside of the Script Task which stands right after the Human Task I restore/insert the facts required for the rule and it works.
Thanks everyone responded!
However, now I’m having another issue which popped up out of nowhere and I fail to figure out what had happened. The problem is that when the Rule Server is restarted with users tasks pending, and then the task is completed by the user the workflow has never been continued. I can see the taskCompleted() event triggered in the Task Event Listener, but it has no effect on the sleeping workflow. However, If after the restart something meaningful has gone through the engine everything starts working fine. Now the question is why my processes aren’t re-hydrated from the disk and completed? Why I need to run a command through the engine to “warm” it up? Load Session instead of Create Session does not help. Besides I do remember it working in my other tests.
Again, any idea would be greatly appreciated!
I found a mistake in my code and now I receive notifications even after the restart. The problem was that I forgot to call .connect() on Task Handler.
taskHandler = new CommandBasedWSHumanTaskHandler(ksession);
//this call is a must to be able to receive notifications...
My apologies to everyone.
I’m now closing this thread as Answered.
Again, thanks everyone for your help and participating!