Raj
Raj

Reputation: 262

Detect rule changes (that I edit using Guvnor) at runtime in my java program

I am using drools-guvnor 5.5 for storing rules and modify using drools-guvnor web-gui. I want to create a sample application in java which connect with drools-guvnor and load rules from it and execute in java side. Steps I followed for this as below.

  1. Create a sample Decision Table in excel.
  2. Upload it in drools-guvnor in package name called "com.sample"

I read in drools-expert documentation that "KnowledgeAgent" is used for connect java application with drools-guvnor but i am not able to find any sample code for that.

Can someone please help me on this issue.

Upvotes: 1

Views: 899

Answers (1)

Steve
Steve

Reputation: 9480

Example code for creating a knowledge agent is in the Drools Expert user guide.

http://docs.jboss.org/drools/release/5.5.0.Final/drools-expert-docs/html_single/#d0e2239

The following is a commented version of the code found in that section of the manual.

// Create a knowledge agent which will poll a Guvnor URL every 60 secs.
KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent( "MyAgent" );
kagent.applyChangeSet( ResourceFactory.newUrlResource( url ) );

// Call this when your application wishes to run rules.
// By calling getKnowledgeBase(), you will get the most recent
// knowledge base from the agent.
KnowledgeBase kbase = kagent.getKnowledgeBase(); 

Upvotes: 2

Related Questions