[rules-users] Working memory - database synchronisation approach

riri irina.adam at gmail.com
Thu Mar 28 08:06:27 EDT 2013


Thank you very much for the quick replies!

I would very much like to avoid having persistence in my rules but I am not
sure how to get notified of changes of an object inside the working memory
so that the service to update it can be called outside the
WorkingMemoryEventListener. 

What I have now is a User entity that has a field which is a
KnowledgeEnvironment. This object is a plain POJO (not Spring bean) that
holds a reference to a KnowledgeAgent and a StatefulKnowledgeSession and has
a method to start a new Thread with fireUntilHalt (and other methods to
create the agent and the session). If I call this method from a unit test
that is marked with @Transactional and have a delay in the thread execution,
the changes get persisted to the database. Without the delay I get an
exception 

Caused by: bitronix.tm.internal.BitronixSystemException: cannot start a new
transaction, transaction manager is shutting down

I imagine this is because the thread is trying to execute after the
transactional context of the unit test has been closed. I do not fully
understand how having access to the Spring context in the separate thread
could help me. Again, I do think that the way I am doing this is flawed
since I need some way to keep the transaction context open so that the
updates can be performed but I have very little experience in the matter.
Should I have a Spring service that is marked with Transactional and can be
called using a KnowledgeSession to span a new thread instead of the method
inside the KnowledgeEnvironment? 

Any insight is highly appreciated!



--
View this message in context: http://drools.46999.n3.nabble.com/Working-memory-database-synchronisation-approach-tp4023094p4023100.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list