[rules-users] Working memory - database synchronisation approach

riri irina.adam at gmail.com
Thu Mar 28 11:26:48 EDT 2013


I may not have explained the architecture I have very well so here it is: I
have plain JPA entities, some of which I want to insert as facts in the
working memory, all entities have repositories defined for them via the
Spring Data JpaRepository and these repositories are called by Spring
Services whenever I need to retrieve, save, delete an entity from the
database. This works well on its own, the methods in the services are all
marked as transactional via AOP pointcuts in the Spring configuration file,
but I want to be able to persist the changes made to an entity from the
working memory to the database and for that I thought about calling the
Spring services inside the WorkingMemoryEventListener.

I think the problem might be with the way I call the fireUntilHalt() method
in a separate thread and the fact that the transaction manager is shut down
at the end of the test, before the entities have time to be updated in the
database. In my test I have 2 rules and the first rule makes modifications
to an entity that trigger the second one. The modifications from the first
rule are saved, the second rule gets triggered but the transaction manager
and the spring context are closed before the update can be made for the
entities in the second rule. Would this be a problem related to the test
itself since in normal functioning the spring application and the
transaction manager would be open unless the whole application is shut down?

I will try and do some more tests to see how to solve this even though I am
not sure if what I am doing is the right way to go. Thank you for the
insight Steve!



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


More information about the rules-users mailing list