I'm looking at code that attempts to do the following:
1. Using JTA, atomically:
a. Write changes to an object to a database using Toplink.
b. Post a message to a JMS topic.
(The topic and the connection pool are both configured to use XA, and Toplink is correctly configured to use an external JTA controller in the WebLogic platform.)
2. After the commit occurs, the message on the topic is consumed. The consumer immediately reads the newly saved object, which is served out of the Toplink session cache.
The problem is that I am seeing a race condition in the message consumer method, such that depending on if or how much I delay, I may or may not see the object modifications from step 1a. If I modify my read-object query to bypass the cache and force a database refresh, I always see the correct result.
I'm trying to determine if Toplink merges changes back into the cache before or after it sends the final ack in the 2PC protocol. I read the excellent timeline in
1033391 and it sounds like it might be "after" (?). If so, it would seem that there is indeed a window of time in which a race can occur in my scenario. Or if not, maybe there is a flaw in this code somewhere that I just can't seem to find.
Thanks.
_Scott