[jboss-user] [JBoss Seam] - TransactionCompletionEvent and @Asynchronous

cpopetz do-not-reply at jboss.com
Tue Dec 18 07:51:57 EST 2007


I have:

Events.instance().raiseTransactionSuccessEvent("doLongWorkAfterTxIsDone");

and 

@Observer("doLongWorkAfterTxIsDone")
public void doWork() {
    aSLSB.anAsyncMethod();
}

where anAsyncMethod() is a method marked @Aysnchronous.  (I'd mark the observer itself as @Asynchronous, but that gets ignored.)  However, anAsyncMethod() isn't called asynchronously, because TransactionCompletionEvent is an AsynchronousEvent, and seam disallows spawning one asynchronous call from another.   But in my case, the CMT tx is committing (and the event is being fired) upon return of a SFSB method that is executed within a web request, i.e. very synchronously as far as the browser is concerned.  

I'm not completely clear on the logic behind disallowing chained async calls, so this may be misguided.  But it seems to me that Asynchronous.execute() should only set EXECUTING_ASYNCHRONOUS_CALL if it indeed sets up a new set of contexts.  That would allow the above code to work.  Of course, it might break something else :)

I have a workaround, which is to raise another asynchronous event from the observer of the transactionComplete event, but that's rather convoluted.


Thanks for any input,
-Clint


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4113740#4113740

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4113740



More information about the jboss-user mailing list