is only reached AFTER the transaction in SessionBean2.method2() finishes! (Although the last statement in SessionBean1.method1() is reached way before that.)
It's as if SessionBean1.method1()'s transaction somehow isn't "released" (for want of a better word -- it does get committed immediately, before the event handler ObserverObject.method2() is called!) until the *asynchronously called* Session2.method2()'s transaction finishes as well.
Does anyone know how I could avoid that?
(The point of the whole setup would be to have the long-running SessionBean2.method2() run in the background after T1's completion and have SessionBean1.method1() return as soon as possible.)
P.S.: I have verified that
a) T1 is committed immediately (the records go in the DB)
b) SessionBean2.method2() is called asynchronously (control jumps to the next statement in the calling code immediately)
c) the SessionBean1.method1() doesn't return control to the caller code until T2 finishes
subject: CDI event originator's transaction waits for Observer(AFTER_SUCCESS) transaction?