[jboss-user] [jBPM] - Use rule to decide flow of process

Mylos Kathos do-not-reply at jboss.com
Mon May 13 09:56:27 EDT 2013


Mylos Kathos [https://community.jboss.org/people/mylos78] created the discussion

"Use rule to decide flow of process"

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

--------------------------------------------------------------
Hi all !
I'm trying to integrate some Drool Rules in a simple process. Basically I'm creating an user class which has some properties:

User user = new User("George",50);

Map<String, Object> params = new HashMap<String, Object>();
params.put("user", user);

ProcessInstance processInstance = ksession.createProcessInstance("DemoProcess", params);

ksession.insert(processInstance);
ksession.insert(user);
ksession.startProcessInstance(processInstance.getId());
ksession.fireAllRules();

When the process is started, there is a Gateway with the following rule in it:

                 --------- Node X
[Start] -----X
                 --------- Node Y

The Rules in the Gateway(X) are:
user.IsAdult   -->Go to Node X
!user.IsAdult  -->Go to Node Y

The problem is that the condition is *always evaluated to Y* because the Rule that sets isAdult seems to be evaluated later (when the process already passed that Gateway)

rule "check user"
   no-loop
when
$p: User( age > 18)
$pi: WorkflowProcessInstanceImpl($user: variables['user']) 
then
$p.setIsAdult(true);

$pi.setVariable("user", $p);

update($p);
end

Is there something I am missing in my process ????
Thanks a lot
Mylos
--------------------------------------------------------------

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

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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20130513/a49211d4/attachment.html 


More information about the jboss-user mailing list