users@glassfish.java.net

Re: EJB _at_Asynchronous method is invoked synchronously when called within the same class

From: CasMeiron <casmeiron_at_gmail.com>
Date: Fri, 6 Aug 2010 09:25:32 -0300

Hi,
TO make async you've got to make the call from the ejb instance, you cannot
make the call this way. Remember, the 'ejb proxy' does the magic, if you re
inside the ejb and call a method, the call will be locally (not using proxy
magic stuff).
You can inject the instance of the same ejb on a field and then make the
invocation to the another method. In this way, the async will work.
-------------------------------
Paulo Reis




On Fri, Aug 6, 2010 at 5:51 AM, Theodor Richard <
theodor.richard_at_googlemail.com> wrote:

> Hello folks,
>
> I have the following stateless session bean:
>
> @Stateless
> @LocalBean
> public class Bean {
> @Asynchronous
> public void methodA(){
> // do something...
> }
>
> @Timeout
> public void methodB(Timer timer) {
> methodA();
> }
> }
>
> When I call methodA from outside the bean, it is invoked asynchronously (as
> expected). However, when methodA is called from methodB, it is invoked
> synchronously. Any explanation for that? I couldn't find anything
> @Asynchronous section of the spec.
>
> Thanks,
> Theo
>