[jbossseam-issues] [JBoss JIRA] Commented: (JBSEAM-1918) Asyncronous methods called from an asyncronously executing methoed will not be invoke asyncronously

Pete Muir (JIRA) jira-events at lists.jboss.org
Wed Mar 4 07:22:22 EST 2009


    [ https://jira.jboss.org/jira/browse/JBSEAM-1918?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12455381#action_12455381 ] 

Pete Muir commented on JBSEAM-1918:
-----------------------------------

Please open a new issue with an example to reproduce.

> Asyncronous methods called from an asyncronously executing methoed will not be invoke asyncronously
> ---------------------------------------------------------------------------------------------------
>
>                 Key: JBSEAM-1918
>                 URL: https://jira.jboss.org/jira/browse/JBSEAM-1918
>             Project: Seam
>          Issue Type: Bug
>          Components: Async
>    Affects Versions: 2.0.0.BETA1
>            Reporter: Chris Rudd
>            Assignee: Pete Muir
>             Fix For: 2.0.0.CR2
>
>
> Currently the AsyncronousInterceptor triggers off of 
>   Contexts.getEventContext().isSet(AbstractDispatcher.EXECUTING_ASYNCHRONOUS_CALL)
> to determine if this invocation was from the asyncronous dispatcher. This works fine, except under the conditions where the asyncronously executed method calls another @asyncronous methd. In that case the Event context alreadt contains the AbstractDispatcher.EXECUTING_ASYNCHRONOUS_CALL marked and the execution is done immedialty instead of being scheduled. 
> I belive a simple resolution would be to have the AsyncronousInterceptor clear the AbstractDispatcher.EXECUTING_ASYNCHRONOUS_CALL before proceeding with the exection, but should only be done if the method in question is an @Asycnronous method. This would be to elimiate possible removal from other components that are called during the process of invoking the asyncronous method (ie injection, security, etc).
> Here is me proposed change :
> AsyncronousInterceptor.java line 24
>   @AroundInvoke
>    public Object aroundInvoke(InvocationContext invocation) throws Exception
>    {
>       boolean scheduleAsync = invocation.getMethod().isAnnotationPresent(Asynchronous.class) && 
>             !Contexts.getEventContext().isSet(AbstractDispatcher.EXECUTING_ASYNCHRONOUS_CALL);
>        if (scheduleAsync)
>        {
>          Dispatcher dispatcher = AbstractDispatcher.instance();
>          if (dispatcher==null)
>          {
>             throw new IllegalStateException("org.jboss.seam.async.dispatcher is not installed in components.xml");
>          }
>          Object timer = dispatcher.scheduleInvocation( invocation, getComponent() );
>          //if the method returns a Timer, return it to the client
>          return timer!=null && invocation.getMethod().getReturnType().isAssignableFrom( timer.getClass() ) ? timer : null;
>       }
> +   else if( invocation.getMethod().isAnnotationPresent(Asynchronous.class) )
> +   {
> +       // Clear the async flag so that any async methods called by this invocation will execute asyncronously
> +       Contexts.getEventContext().remove( AbstractDispatcher.EXECUTING_ASYNCHRONOUS_CALL );
> +       return invocation.proceed();
> +    }
>       else
>       {
>          return invocation.proceed();
>       }
>    }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the seam-issues mailing list