DecisionTaskTimedOut当@Asynchronous注释用于 [英] DecisionTaskTimedOut when @Asynchronous annotation is used

查看:433
本文介绍了DecisionTaskTimedOut当@Asynchronous注释用于的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些两套活性需要并行地执行的。他们成功完成后,我想执行另一组活动。我用任务和它的工作。但是,使用@Asynchronous注释后,我收到DecisionTaskTimedOut,没有活动的开始执行。我AspectJ的配置工作,因为我可以看到下面的类我的目标:

I have some two sets of activity that needs to be executed in parallel. After their successful completion, I want to execute another set of activity. I used Task and it was working. But, after using the @Asynchronous annotation, I am getting the DecisionTaskTimedOut and none of the activity starts its execution. My aspectj configuration is working as i can see the following classes in my target:

AsyncWorkflowImpl $ AjcClosure1.class

AsyncWorkflowImpl$AjcClosure1.class

AsyncWorkflowImpl $ AjcClosure3.class

AsyncWorkflowImpl$AjcClosure3.class

AsyncWorkflowImpl $ AjcClosure5.class

AsyncWorkflowImpl$AjcClosure5.class

异步版本

 public class AsyncWorkflowImpl implements AsyncWorkflow{

        private AsyncActivitiesClient activitiesClient = new AsyncActivitiesClientImpl();
        private Async2ActivitiesClient activitiesClient2 = new Async2ActivitiesClientImpl();

        @Override
        public void executeActivity() {

            Promise<Integer> intermediateRes = null;
            Promise<Integer> intermediateRes2 = null;
            for(int i=0; i<5; i++){
                intermediateRes = testIntermediate(Promise.asPromise(i), intermediateRes);
            }
            for(int i=0; i<5; i++){
                intermediateRes2 = testIntermediate2(Promise.asPromise(i), intermediateRes2);
            }
            test(intermediateRes,intermediateRes2);
        }

        @Asynchronous
        public Promise<Integer> testIntermediate(final Promise<Integer> i, Promise<Integer> res){

            return  activitiesClient.testAct1(i); 
        }

        @Asynchronous
        public Promise<Integer> testIntermediate2(final Promise<Integer> i, Promise<Integer> res){
            return  activitiesClient2.testAct1(i); 
        }

        @Asynchronous
        public void test(final Promise<Integer> res, final Promise<Integer> res2){

            activitiesClient.testAct2();
        }

    }

任务版

public class AsyncWorkflowImpl implements AsyncWorkflow{

    private AsyncActivitiesClient activitiesClient = new AsyncActivitiesClientImpl();
    private Async2ActivitiesClient activitiesClient2 = new Async2ActivitiesClientImpl();

    @Override
    public void executeActivity() {

        Promise<Integer> intermediateRes = null;
        Promise<Integer> intermediateRes2 = null;
        Settable<Integer> finalRes = new Settable<Integer>();
        Settable<Integer> finalRes2 = new Settable<Integer>();
        for(int i=0; i<5; i++){
            intermediateRes = testIntermediate(i, intermediateRes);
        }
        for(int i=0; i<5; i++){
            intermediateRes2 = testIntermediate2(i, intermediateRes2);
        }
        finalRes.chain(intermediateRes);
        finalRes2.chain(intermediateRes2);
        test(finalRes,finalRes2);
    }

    public Promise<Integer> testIntermediate(final Integer i, Promise<Integer> res){
        final Settable<Integer> tempRes = new Settable<Integer>();
        new Task(res){
            @Override
            protected void doExecute() throws Throwable {

                tempRes.chain(activitiesClient.testAct1(i)); 
            }
        };
        return tempRes;
    }

    public Promise<Integer> testIntermediate2(final Integer i, Promise<Integer> res){
        final Settable<Integer> tempRes = new Settable<Integer>();
        new Task(res){
            @Override
            protected void doExecute() throws Throwable {

                tempRes.chain(activitiesClient2.testAct1(i)); 
            }
        };
        return tempRes;
    }

    public void test(final Promise<Integer> res, final Promise<Integer> res2){

        new Task(res, res2){
            @Override
            protected void doExecute() throws Throwable {

                activitiesClient.testAct2();
            }
        };
    }
}

有没有在AspectJ织什么问题?任何建议是高度AP preciated。

Is there any problem in aspectj weaving? Any suggestion is highly appreciated.

推荐答案

这是<一href="http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/simpleworkflow/flow/annotations/Asynchronous.html"相对=nofollow> @异步方法执行时的所有准备。因为 RES 的参数,这是从来没有准备好您的@Asynchronous方法是永远不会被执行。解决的办法是标注这些参数与<一个href="http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/index.html?com/amazonaws/services/simpleworkflow/flow/annotations/NoWait.html"相对=nofollow> @ NOWAIT 以告知,这些不应该等待的框架。

An @Asynchronous method is executed when all of its parameters that extend type Promise are ready. Your @Asynchronous methods are never executed because of the res parameter which is never ready. The solution is to annotate such parameters with @NoWait to inform the framework that these should not be waited.

解决出现的工作流的最佳方式卡是看它包含所有未完成的任务异步堆栈跟踪他们的异步堆栈跟踪。使用<一个href="https://github.com/aws/aws-sdk-java/blob/master/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/common/WorkflowExecutionFlowThreadDumper.java"相对=nofollow> WorkflowExecutionFlowThreadDumper 发出这样的痕迹。

The best way to troubleshoot workflows that appears "stuck" is by looking at their "asynchronous stack trace" that contains async stack traces of all outstanding tasks. Use WorkflowExecutionFlowThreadDumper to emit such a trace.

这篇关于DecisionTaskTimedOut当@Asynchronous注释用于的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆