[rules-users] Value is not reflected in Fact Object at Drool Client Side

Hushen Savani hushen.savani at elitecore.com
Wed Dec 5 04:44:09 EST 2012


I looked into example of mortgage. What I find most confusing is Knowledge
Agent name provided in KnowledgeAgentFactory.newKnowledgeAgent(..) . Like in
mortgage example, the KnowledgeBase is created using this method:

 

private static KnowledgeBase readKnowledgeBase() {

        KnowledgeAgent kagent =
KnowledgeAgentFactory.newKnowledgeAgent("MortgageAgent");

        Resource changeset = ResourceFactory.newClassPathResource(

 
"org/drools/guvnor/examples/mortgage/mortgage-changeset.xml");

        kagent.applyChangeSet(changeset);

        KnowledgeBase kbase = kagent.getKnowledgeBase();

        kagent.dispose();

        return kbase;

}

 

I find it difficult where does "MortgageAgent" is set in Guvnor?? 

 

Pls. suggest some pointers. Thanks.

 

Best Regards

Hushen Savani 

 

From: rules-users-bounces at lists.jboss.org
[mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Michael Anstis
Sent: Wednesday, December 05, 2012 1:40 PM
To: Rules Users List
Subject: Re: [rules-users] Value is not reflected in Fact Object at Drool
Client Side

 

There is a mortgages example in the Guvnor distribution.

/guvnor-distribution-5.x.0.Final/examples/sources/src/main/java/org/drools/g
uvnor/examples/

On 5 December 2012 08:06, Esteban Aliverti <esteban.aliverti at gmail.com>
wrote:

I'm wondering where did you get the content of that Guvnor.properties file.
The problem you are having is that the property file is not used to tell the
agent which resources should it use, but to set some of its internal
configurations such as:

*	drools.agent.monitorChangeSetEvents (boolean)
*	drools.agent.scanDirectories (boolean)
*	drools.agent.scanResources (boolean)
*	drools.agent.newInstance (boolean)
*	drools.agent.useKBaseClassLoaderForCompiling (boolean)
*	drools.agent.validationTimeout (long)

So, the properties you have there are not even being user, nor understood,
by drools.

In order to tell the agent which resources should it use, you must provide a
change-set pointing to those resources. You can find more information about
change-sets in Drools documentation.

 

Best Regards,  





XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Esteban Aliverti
- Blog @ http://ilesteban.wordpress.com





On Wed, Dec 5, 2012 at 8:52 AM, Hushen Savani <hushen.savani at elitecore.com>
wrote:

It seems that problem is with rule consumer (client), because even when I
mess up with url of guvnor, it is giving me the same behavior:

 

Guvnor.properties:

 

url=http://localhost:10080/
guvnor-5.5.0.Final-tomcat-6.0/org.drools.guvnor.Guvnor/package/new
Pkg/car111_messed_up_url

enableBasicAuthentication=true

username=admin

password=admin

name=drooltest

 

 

Drool Consumer:

 

package kijanowski.eu;

 

import java.util.Collection;

import java.util.Iterator;

 

import org.drools.KnowledgeBase;

import org.drools.agent.KnowledgeAgent;

import org.drools.agent.KnowledgeAgentFactory;

import org.drools.runtime.StatefulKnowledgeSession;

 

public class GuvnorTest {

 

        public static final void main(String[] args) {

 

                  KnowledgeAgent agent =
KnowledgeAgentFactory.newKnowledgeAgent("/Guvnor.properties"); 

                  KnowledgeBase ruleBase = agent.getKnowledgeBase();

 

                  StatefulKnowledgeSession workingMemory =
ruleBase.newStatefulKnowledgeSession();

                          

                Driver d = new Driver("Jarek", 20, null);

                workingMemory.insert(d);

 

                workingMemory.fireAllRules();

                

                Collection c = workingMemory.getObjects();

                

                for(Iterator i = c.iterator(); i.hasNext();) {

 
//System.out.println(i.next().getClass().getCanonicalName());

                  Driver e = (Driver)i.next();

                  System.out.println(" Age: " + e.getAge() + " Name: " +
e.getName() + " Car: " + e.getCar() + " Object: " + e);

                }

        }

}

 

Can anyone please suggest some pointers on the same.

 

Thanks.

 

Best Regards

Hushen Savani

 

From: rules-users-bounces at lists.jboss.org
[mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Esteban Aliverti
Sent: Tuesday, December 04, 2012 9:38 PM
To: Rules Users List
Subject: Re: [rules-users] Value is not reflected in Fact Object at Drool
Client Side

 

Sorry, I've just re-read your post and saw that you already mentioned that
you are not seeing the system.out of your rule.

What you can do is to debug (or add some code) to see which rules do you
have in the kbase returned by the kagent.

My guess is that your are not getting what you are expecting from Guvnor.

 

Best Regards,  



XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Esteban Aliverti
- Blog @ http://ilesteban.wordpress.com

On Tue, Dec 4, 2012 at 5:03 PM, Esteban Aliverti
<esteban.aliverti at gmail.com> wrote:

Do you see the message you are printing in the RHS of your rule?

 

Best Regards,



XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Esteban Aliverti
- Blog @ http://ilesteban.wordpress.com

 

On Tue, Dec 4, 2012 at 3:28 PM, Mister Nono <noel.maurice at univ-jfc.fr>
wrote:

Hi,

Have you try to add in the then of the drools rule the line : *update(a);*

Best regards. ;)



--
View this message in context:
http://drools.46999.n3.nabble.com/rules-users-Value-is-not-reflected-in-Fact
-Object-at-Drool-Client-Side-tp4021067p4021068.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
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

 


_______________________________________________
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/20121205/04a43ce8/attachment-0001.html 


More information about the rules-users mailing list