[rules-users] Drools Flow - Session objects

Gustavo Tenrreiro gustavo at tenrreiro.com
Thu Sep 2 12:15:26 EDT 2010


It looks to me like it should work, as you point out.

Thanks

On Wed, Sep 1, 2010 at 10:12 AM, jawa <agohar at gmail.com> wrote:
>
> Hi,
>
> I am writing a small drools flow app. My flow starts off with a RuleGroup
> node then I've two User Task nodes. What i do is this:
>
> StatefulKnowledgeSession session =
> JPAKnowledgeService.newStatefulKnowledgeSession(knowledgeBase, null,
> environment);
> WorkItemManager manager = session.getWorkItemManager();
> manager.registerWorkItemHandler("Human Task", new MyWorkItemHandler(false));
> MyVO vo = new MyVO();
> vo.setComment("These are comments !!");
> session.insert(vo);
> ProcessInstance processInstance = session.startProcess("pocflow", null);
> session.fireAllRules();
> session.dispose();
>
> As you can see i am inserting an object of type MyVO into the knowledge base
> session. I am using JPA to store my flow in db. Now when I execute this
> code, it starts my flow then calls my drl file for RuleGroup node then calls
> human tasks etc. In my drl file I've this code:
>
> package mypackage
> import net.plus.kbd.poc.MyVO;
>
> rule "Displaycomments"
> ruleflow-group "display_comments"
>        when $vo: MyVO()
>        then
>                System.out.println("Inside Rule->MyVoComments->" + $vo.getComment());
> end
> rule "NotDisplaycomments"
> ruleflow-group "display_comments"
>        when not $v: MyVO()
>        then
>                System.out.println("Inside Rule->MyVoComments not found");
> end
>
> So when this rule gets executed it always run "NotDisplaycomments" rule and
> prints out that MyVoComments not found. As far as I know it should find my
> vo which i inserted into the session. isn't it?
>
> I am using drools 5.1.1 on jboss 5.
>
> Any idea what am I doing wrong?
>
> Thanks
>
> --
> View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Drools-Flow-Session-objects-tp1400891p1400891.html
> Sent from the Drools - User mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>




More information about the rules-users mailing list