[rules-users] Knowledge Base and Guvnor

Dean Whisnant dean at basys.com
Mon Jan 3 15:03:32 EST 2011


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




More information about the rules-users mailing list