Cache Invalidation
jwr Jun 11, 2003 3:17 PMHello!
I have a subtle problem with cache invalidation. I modified the downloadable test program "template" a little bit so that I can modify a "BookEntity" (which resembles a "TestEntity" but holds a book's data). I also read the article under http://www.onjava.com/pub/a/onjava/2003/05/28/jboss_optimization.html and configured my jboss.xml in the way:
<ejb-name>BookEntity</ejb-name>
<jndi-name>ejb/at/xion/xbib/BookEntity</jndi-name>
<configuration-name>Standard CMP 2.x EntityBean with cache invalidation</configuration-name>
<method-attributes>
<method-name>get*</method-name>
<read-only>true</read-only>
</method-attributes>
<cache-invalidation>true</cache-invalidation>
When I change the book title on node A (via a session bean, that calls the entity bean's method "updateValueObject" which calls setTitle() in turn), I receive the following message on node B:
2003-06-12 20:53:33,257 DEBUG [org.jboss.ha.framework.interfaces.HAPartition.DefaultPartition] Partition DefaultPartition received msg
2003-06-12 20:53:33,291 DEBUG [org.jboss.ha.framework.interfaces.HAPartition.DefaultPartition] pre methodName: DCacheBridge-DefaultJGBridge._rpc_batchInvalidate
2003-06-12 20:53:33,291 DEBUG [org.jboss.ha.framework.interfaces.HAPartition.DefaultPartition] handlerName: DCacheBridge-DefaultJGBridge methodName: _rpc_batchInvalidate
2003-06-12 20:53:33,292 DEBUG [org.jboss.ha.framework.interfaces.HAPartition.DefaultPartition] Handle: DCacheBridge-DefaultJGBridge._rpc_batchInvalidate
When I search for the book with the new title on node B, I find the book, but when I write the book data to the console, the OLD (!!!!) title is shown. The entity bean is read from the cache, no ejbLoad() method is triggered. When I search for all books with the findAll() method, I also see the old (stale) book title.
So how does the new book title come from node A to node B? Why does the output on node B still produce the stale data? Why is the entity bean not loaded from the database?
I do not use any transaction code other than the xdoclet directive * @ejb:transaction type="Required".
Can you help me?
Best regards from Austria,
Joe.