Still working on StoreAndForwardTest. I put a sequence diagram together to help reason about what I'm seeing and attached it here: https://test.kuali.org/confluence/display/KULRICE/Store+and+Forward+implementation
It appears to be a timing issue: after the service method is invoked on the destination service from the KSB-Pool thread, it goes to delete the PersistedMessage. At about the same time, the main thread's MessageServiceInvoker is trying to delete it's copy of the PersistedMessage. Almost all of the time this is resulting in an OptimisticLockException when I'm testing. It didn't happen with OJB, but I'm guessing it was just due to fortunate timing – I may be wrong though.
So here are a few questions:
1. Why is the PersistedMessage being persisted at all? It doesn't seem to ever be retrieved during its lifetime.
2. Any idea why the ForwardedCallHandler makes a copy of the PersistedMessage and then does nothing with it?
3. I have one hypothesis, which is that the ForwardedCallHandler is actually supposed to pass on the copy it made of the PersistedMessage, which would then be saved / deleted in a separate row and no OptimisticLockException would occur. Does that sound plausible?
In the truly asynchronous case (without the SynchronousServiceCallProxy involved), it seems like the persisted message would be stored and deleted rather quickly, then stored and deleted again. I'm not sure what the point is.