[rules-users] Timer node issue when using ksession created with JPAKnowledgeService

nanic23 nanic23 at hotmail.com
Thu Apr 15 12:27:48 EDT 2010


Hi all,

I successfully implemented a Timer node and trigger it by doing:

final StatefulKnowledgeSession ksession =
knowledgeBase.newStatefulKnowledgeSession();
		
new Thread(new Runnable() {
	public void run() {
		ksession.fireUntilHalt();	
	}
}).start();

But when I've drools persistence in place and use the JPAKnowledgeService to
create the knowledge session the timer doesn't run at all. I checked and the
thread is being spawned but when ksession.fireUntilHalt() is called nothing
happens. 

final StatefulKnowledgeSession ksession = JPAKnowledgeService
.newStatefulKnowledgeSession(knowledgeBase, null, env);

new Thread(new Runnable() {
	public void run() {
		ksession.fireUntilHalt();	
	}
}).start();

Environment looks like this:
		Environment env = KnowledgeBaseFactory.newEnvironment();
		env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);
		env.set(EnvironmentName.GLOBALS, new MapGlobalResolver());


I am trying different things but haven't been able to make it work yet.

So, the question is: Can I run a timer when having drools persistence in
place? If yes, how can I achive this?

Any tips and/or ideas are appreciated.

Thanks,

Nick.

P.S. I "kind" of answered my own questions but I have some other new
questions :) Please keep reading below!

---------------------------------------------

I was able to fire the timer when having drools persistence in place using
ksession created with JPAKnowledgeService. I got it running by calling
ksession.fireAllRules() instead of ksession.fireUntilHalt();

QUESTIONS: 
a. is it ok to fire a timer by calling fireAllRules()?
b. should we still be able to fire the timer with fireUntilHalt() in this
situation?
c. are there any difference to be considered when firing with fireAllRules()
vs. fireUntilHalt()?

Thanks,

Nick. 
-- 
View this message in context: http://n3.nabble.com/Timer-node-issue-when-using-ksession-created-with-JPAKnowledgeService-tp721630p721630.html
Sent from the Drools - User mailing list archive at Nabble.com.



More information about the rules-users mailing list