[rules-users] Knowledge Base and Guvnor

Esteban Aliverti esteban.aliverti at gmail.com
Fri Jan 14 15:14:42 EST 2011


Depending on the amount of rules you have, compilation could be expensive. I
recommend you to use the binary format instead of the drl.
You already figured out the things you need to change in your code, so there
is nothing else to say.

Best Regards,

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

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


2011/1/6 Dean Whisnant <dean at basys.com>

> A bit of a follow-up on this:
>
>
>
> When I build the package inside of Guvnor it shows me the following on the
> package build screen:
>
> *Last Modified:*
>
> *Wednesday, January 05, 2011 12:22:25 PM*
>
> *Last contributor:*
>
> *admin*
>
> *Date created:*
>
> *Wednesday, January 05, 2011 12:15:42 PM*
>
> *Show package source:*
>
> *Show package source*
>
> *URL for package documentation:*
>
> *
> http://vmjboss:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/A_RDR_v9/LATEST/documentation.pdf
> *
>
> *[image: Description:
> http://vmjboss:8080/drools-guvnor/org.drools.guvnor.Guvnor/images/information.gif]
> ***
>
> *URL for package source:*
>
> *
> http://vmjboss:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/A_RDR_v9/LATEST.drl
> *
>
> *[image: Description:
> http://vmjboss:8080/drools-guvnor/org.drools.guvnor.Guvnor/images/information.gif]
> ***
>
> *URL for package binary:*
>
> *
> http://vmjboss:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/A_RDR_v9/LATEST
> *
>
> *[image: Description:
> http://vmjboss:8080/drools-guvnor/org.drools.guvnor.Guvnor/images/information.gif]
> ***
>
> *URL for running tests:*
>
> *
> http://vmjboss:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/A_RDR_v9/LATEST/SCENARIOS
> *
>
> *[image: Description:
> http://vmjboss:8080/drools-guvnor/org.drools.guvnor.Guvnor/images/information.gif]
> ***
>
> *Change Set:*
>
> *
> http://vmjboss:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/A_RDR_v9/LATEST/ChangeSet.xml
> *
>
> *[image: Description:
> http://vmjboss:8080/drools-guvnor/org.drools.guvnor.Guvnor/images/information.gif]
> ***
>
> *Status:*
>
> *[image: Description:
> http://vmjboss:8080/drools-guvnor/org.drools.guvnor.Guvnor/images/edit.gif]
> ***
>
>
>
> In the example below you showed how I could use the .drl, but is there an
> advantage for me to directly use the package here? Or say I create a package
> snapshot and it gives me the following url
>
> *
> http://vmjboss:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/A_RDR_v9/20110106
> *
>
>
>
> Does using this package decrease the runtime inside of my app because
> Guvnor has pre-built the tables?
>
>
>
> If so, based on the example below, how would I implement using something
> like this package snapshot?  Would it be as simple as:
>
>
>
> *final String STANDARD_URL=
> http://vmjboss:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/A_RDR_v9/20110106
> ;*
>
>
>
> and then
>
>
>
>                 *kbuilder.add( standardUrlResource, ResourceType.PKG);*
>
>
>
> leaving all other lines the same?
>
>
>
> Thank you!
>
>
>
> Dean Whisnant
>
>
>
>
>
> *From:* rules-users-bounces at lists.jboss.org [mailto:
> rules-users-bounces at lists.jboss.org] *On Behalf Of *Michael Anstis
> *Sent:* Tuesday, January 04, 2011 3:31 AM
> *To:* Rules Users List
> *Subject:* Re: [rules-users] Knowledge Base and Guvnor
>
>
>
> Hi,
>
>
> You should be able to use the URL syntax with KnowledgeBuilder as follows:-
>
> final String STANDARD_URL = "
> http://your-guvnor-instance-host/org.drools.guvnor.Guvnor/package/standard/LATEST.drl
> ";
> final String CUSTOMER_URL="
> http://your-guvnor-instance-host/org.drools.guvnor.Guvnor/package/customer/LATEST.drl
> ";
>
> KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
>
> UrlResource standardUrlResource =
> (UrlResource)ResourceFactory.newUrlResource(STANDARD_URL);
> standardUrlResource.setBasicAuthentication("enabled");
> standardUrlResource.setUsername("xyz");
> standardUrlResource.setPassword("abc");
>
> UrlResource customerUrlResource =
> (UrlResource)ResourceFactory.newUrlResource(CUSTOMER_URL);
> customerUrlResource.setBasicAuthentication("enabled");
> customerUrlResource.setUsername("xyz");
> customerUrlResource.setPassword("abc");
>
> kbuilder.add( standardUrlResource, ResourceType.DRL);
> kbuilder.add( customerUrlResource, ResourceType.DRL);
>
> assertFalse( kbuilder.hasErrors() );
> KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
>
> I don't think you'd need to (or want to) create two KnowledgeBases: You
> could ensure "standard" rules are applied first by any of Drools' agenda
> controls; i.e. salience, agenda-group or ruleflow; plus sharing a single
> KnowledgeBase ensures rules in both packages that share patterns are
> optimissed in the RETE network.
>
> Use of ChangeSet could make things a little simpler too (rather than the
> individual UrlResources).
>
> Cheers,
>
> Mike
>
> On 3 January 2011 20:03, Dean Whisnant <dean at basys.com> wrote:
>
> Hi all, thank you for all the help in the past.
>
> I'm to a point in my project of implementing Guvnor built packages into my
> java code that calls drools.
>
> In the past I used the simple solution of building the knowledge agent on a
> .drl file as follows:
>
>        //Setup the knowledge session for drools
>        private static KnowledgeBase readKnowledgeBase() throws Exception {
>                KnowledgeBuilder kbuilder = KnowledgeBuilderFactory
>                                .newKnowledgeBuilder();
>
>  kbuilder.add(ResourceFactory.newClassPathResource("Standard837P.drl"),
>                                ResourceType.DRL);
>                KnowledgeBuilderErrors errors = kbuilder.getErrors();
>                if (errors.size() > 0) {
>                        for (KnowledgeBuilderError error : errors) {
>                                System.err.println(error);
>                        }
>                        throw new IllegalArgumentException("Could not parse
> knowledge.");
>                }
>                KnowledgeBase kbase =
> KnowledgeBaseFactory.newKnowledgeBase();
>                kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
>                return kbase;
>        }
>
> A little background before the question.  My project includes one set of
> rules that are standard business logic, we'll call that STANDARD for now and
> one set of rules that any one of my 45 customers could have created, we'll
> call CUSTOMER, on our common guvnor server.  My java code knows which
> customer is running the app, so determining which two packages I want to
> fire is simple.  The part that is not as straight forward for me is how I
> then I migrate using the guvnor urls in my above code.
>
> I thought it would be as easy as to replace "Standard837P.drl" above with
> the STANDARD url and create a second add that would use the CUSTOMER url.
>
> I also want all of my STANDARD rules applied before my CUSTOMER rules are
> applied.  This got me thinking that I need to have two independent knowledge
> bases running so that I fire all in the first and then fire all in the
> second.
>
> Backing up a bit again, my application looks through an incoming file
> inserting facts into the knowledge base for one medical claim line item,
> fires rules, writes out results to a database, and then moves on to the next
> claim line item in the file.
>
> 1) What would the syntax need to be to implement the STANDARD and CUSTOMER
> urls?
> 2) Would I need to create two independent knowledge bases?
> 3) DO you see any performance issues in this arrangement?
>
> Thank you!
>
> Dean
>
> _______________________________________________
> 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/20110114/eafd2b9f/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/gif
Size: 267 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/rules-users/attachments/20110114/eafd2b9f/attachment.gif 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/gif
Size: 210 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/rules-users/attachments/20110114/eafd2b9f/attachment-0001.gif 


More information about the rules-users mailing list