[rules-users] 6.0.1.F Need help in getting recanned rules into new session

SrjTx clickthex at yahoo.com
Wed Mar 26 16:26:32 EDT 2014


I've have been unable to figure out how to get drools to rescan and then use
the updated rules in a new session.  I currently have to restart jboss to
pick up the changes.  The scanning seems to happen, but I don't see the
changes that should be included.


I have looked at lots of example code on the web and also at the Switchyard
source.  When I do this in tandem with SY, I can get it to work, but I
need/want to have it work on its own.

I have tried some different combinations with no luck.

In addition to the "why doesn't it work", I would like to clearly
understand:


Do I need a KieBase, or should I just be creating sessions off of the
container?

What do I need to have in Envinonment?.
What do I need to have in ksessionConfiguration?
Related, what is the proper mechanism to pass in the Session Name?



GAD is: com.xyz.policy, cep, 1.0
Drools session is stateful and named "DroolsSession", stream processing
mode, realtime




I initialized KIE with the following.

		kieServices = KieServices.Factory.get();

		releaseId = kieServices.newReleaseId("com.xyz.policy", "cep",
				"LATEST");

		kieFileSystem = kieServices.newKieFileSystem().generateAndWritePomXML(
				releaseId);

		kieBuilder = kieServices.newKieBuilder(kieFileSystem);

		kieBuilder.buildAll();

		Results results = kieBuilder.getResults();
		if (results.hasMessages(Message.Level.ERROR)) {
			StringBuilder sb = new StringBuilder();
			for (Message message : results.getMessages(Message.Level.ERROR)) {
				if (sb.length() != 0) {
					sb.append(" -- ");
				}
				sb.append(message.toString().trim());
			}
			log("Unable to initialize KIE " + sb.toString());

		} else {
			env = kieServices.newEnvironment();

			kieContainer = kieServices.newKieContainer(releaseId);
			kieScanner = kieServices.newKieScanner(kieContainer);

			kieBaseConfiguration = kieServices.newKieBaseConfiguration();
			kieBase = kieContainer.newKieBase(kieBaseConfiguration);

			kieSessionConfiguration = kieServices.newKieSessionConfiguration();
			kieSessionConfiguration.setProperty("sessionName", "DroolsSession");
			kieSessionConfiguration.setProperty("drools.clockType", "realtime");
			kieSessionConfiguration.setProperty("drools.evenProcessingMode",
					"stream");

	
Later when I determine it is time to rescan, I do the following:	
	
					kieScanner.scanNow();

					System.err.println("Scanning...");

					currentKieSessionThread = new KieSessionThread(
							kieBase.newKieSession(kieSessionConfiguration, env));

					executorBean.execute(currentKieSessionThread);




--
View this message in context: http://drools.46999.n3.nabble.com/6-0-1-F-Need-help-in-getting-recanned-rules-into-new-session-tp4028975.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list