Hi All
I am not able to get the updated rules still i used change set , can any one
plz sort out this problem
The source code is
using this program i am printing the rule name in package for every five
seconds.
for first time it prints rule names in package, after that packages are not
available in kbase...
import org.drools.KnowledgeBase;
import org.drools.KnowledgeBaseFactory;
import org.drools.agent.KnowledgeAgent;
import org.drools.agent.KnowledgeAgentFactory;
import org.drools.builder.KnowledgeBuilder;
import org.drools.builder.KnowledgeBuilderError;
import org.drools.builder.KnowledgeBuilderErrors;
import org.drools.builder.KnowledgeBuilderFactory;
import org.drools.builder.ResourceType;
import org.drools.definition.KnowledgePackage;
import org.drools.io.ResourceChangeScannerConfiguration;
import org.drools.io.ResourceFactory;
import org.drools.logger.KnowledgeRuntimeLogger;
import org.drools.logger.KnowledgeRuntimeLoggerFactory;
import org.drools.runtime.StatefulKnowledgeSession;
import org.drools.runtime.StatelessKnowledgeSession;
import org.drools.agent.*;
public class ChangeSet1
{
private ChangeSet1()
{
}
public static synchronized ChangeSet1 start()
{
try{
if ( _instance == null)
{
_instance = new ChangeSet1();
String url="file:H:\\RuleFiles\\ChangeSet.xml";
_kagent = KnowledgeAgentFactory.newKnowledgeAgent( "MyAgent" );
System.out.println("after creating kagent");
_kagent.applyChangeSet(ResourceFactory.newUrlResource(url));
System.out.println("after apply change set");
//Create Knowledge Base
_kbase = _kagent.getKnowledgeBase();
ResourceChangeScannerConfiguration sconf=
ResourceFactory.getResourceChangeScannerService().newResourceChangeScannerConfiguration();
sconf.setProperty("drools.resource.scanner.interval", "5");
ResourceFactory.getResourceChangeScannerService().configure(sconf);
ResourceFactory.getResourceChangeNotifierService().start();
ResourceFactory.getResourceChangeScannerService().start();
System.out.println("After starting Notification service");
}
}catch(Exception e)
{
System.out.println(e.getMessage());
}
return _instance;
}
private static KnowledgeAgent _kagent;
private static ChangeSet1 _instance;
private static KnowledgeBase _kbase=null;
private static StatelessKnowledgeSession _ksession=null;
public static void main(String[] args)
{
int counter=0;
try
{
System.out.println("Before rule engine start ");
ChangeSet1.start();
System.out.println("After rule engine start ");
do{
_kbase = _kagent.getKnowledgeBase();
Collection<KnowledgePackage> kpackages =
_kbase.getKnowledgePackages();
System.out.println("no of packages"+kpackages.size());
for(KnowledgePackage kpackage : kpackages)
{
for(org.drools.definition.rule.Rule rule1
:kpackage.getRules())
{
String packname= rule1.getPackageName();
String rulename=rule1.getName();
System.out.println("This is : "+packname+" Packages and
RuleName is " +rulename);
}
}
counter++;
try{
Thread.sleep(10000);
}catch (InterruptedException e){
System.out.println("Sleep exception occured");
}
}while(counter < 10000);
}catch (Throwable t){
t.printStackTrace();
}
}
}
This is my changeset.xml
<change-set
xmlns='http://drools.org/drools-5.0/change-set'
xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'
xs:schemaLocation='http://drools.org/drools-5.0/change-set
http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/...
<add
<resource
source='http://localhost:8080/guvnor-5.3.0.Final-jboss-as-5.1/rest/packages/pricing/source'
type='DRL' /
<resource
source='http://localhost:8080/guvnor-5.3.0.Final-jboss-as-5.1/rest/packages/search/source'
type='DRL' /
</add
</change-set
Output:--
Before rule engine start
after creating kagent
after apply change set
After starting Notification service
After rule engine start
no of packages2
This is : pricing Packages and RuleName is ageprice
This is : pricing Packages and RuleName is incomeprice
This is : pricing Packages and RuleName is cpvprice
This is : search Packages and RuleName is age
This is : search Packages and RuleName is income
This is : search Packages and RuleName is cpv
no of packages0
<after updating package count is 0 so no rules
no of
packages0
no of packages0
--
View this message in context:
http://drools.46999.n3.nabble.com/unable-to-update-the-changes-guvnor-rul...
Sent from the Drools: User forum mailing list archive at
Nabble.com.