Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用Spring的简单工作流(SWF),无需xml_Java_Spring_Spring Mvc_Amazon Web Services_Amazon Swf - Fatal编程技术网

Java 使用Spring的简单工作流(SWF),无需xml

Java 使用Spring的简单工作流(SWF),无需xml,java,spring,spring-mvc,amazon-web-services,amazon-swf,Java,Spring,Spring Mvc,Amazon Web Services,Amazon Swf,目前,我正在根据为Activity Worker和Workflow Worker开发基于spring注释的依赖项注入。我已经在spring boot应用程序中定义了我的bean。每个工人都在单独的maven模块中定义。我面临的问题是,当运行ActivityWorker spring启动模块时,它会保持活动状态并开始查找活动,但workflow worker在启动模块后会立即停止,并显示消息' 关闭时注销JMX公开的bean 我的执行情况如下: @Activities(version = "2.2

目前,我正在根据为Activity Worker和Workflow Worker开发基于spring注释的依赖项注入。我已经在spring boot应用程序中定义了我的bean。每个工人都在单独的maven模块中定义。我面临的问题是,当运行ActivityWorker spring启动模块时,它会保持活动状态并开始查找活动,但workflow worker在启动模块后会立即停止,并显示消息'

关闭时注销JMX公开的bean

我的执行情况如下:

@Activities(version = "2.2")
@ActivityRegistrationOptions(defaultTaskScheduleToStartTimeoutSeconds = 300, defaultTaskStartToCloseTimeoutSeconds = 100)

public interface TempActivities {
    public GreetWrapper getName();
    public void say(String what);
    /* public Integer doProcess();
    public int sum(Integer num);*/
}

public class TempActivitiesImpl implements TempActivities {
    GreetWrapper greetObj = new GreetWrapper();
    public TempActivitiesImpl() {
        // TODO Auto-generated constructor stub
    }
    @Override
    public GreetWrapper getName() {
        greetObj.setGreet("World");
        return greetObj;
    }

    @Override
    public void say(String what) {
        System.out.println(what);
    }
}
@Workflow(dataConverter = GreetWrapper.class)
@WorkflowRegistrationOptions(defaultExecutionStartToCloseTimeoutSeconds = 3600)
public interface TempWorkflow {
    @Execute(name = "TempWorkflow", version = "2.2")
    public void greet();
}
public class TempWorkflowImpl implements TempWorkflow {

    private TempActivitiesClient activitiesClientImpl = new TempActivitiesClientImpl();
    private DecisionContextProvider contextProvider = new DecisionContextProviderImpl();

    private WorkflowClock clock
        = contextProvider.getDecisionContext().getWorkflowClock();
    @Override
    public void greet() {
        greet1(0);
    }

    public void greet1(int count,
        Promise < ? > ...waitFor) {
        if (count == 3) {
            return;
        }
        Promise < GreetWrapper > name = activitiesClientImpl.getName();
        Promise < String > greeting = getGreeting(name);
        activitiesClientImpl.say(greeting);
        Promise < Void > timer = clock.createTimer(30);
        greet1(count + 1, timer);
    }
    @Asynchronous
    public Promise < String > getGreeting(Promise < GreetWrapper > name) {
        String greeting = "Hello " + name.get().getGreet();
        System.out.println("Greeting: " + greeting);
        return Promise.asPromise(greeting);
    }
}
这是我的工作流工作bean

public class WorkFlowAppConfig {

    public String getActivityTasklistName() {
        return "HelloWorldTaskList";
    }

    public String getDomainName() {
        return "helloWorldWalkthrough2";
    }

    public String getWorkflowTasklistName() {
        return "HelloWorldWorkflow";
    }
    public String getEndPoint() {
        String endPoint = "https://swf.us-east-1.amazonaws.com";
        return endPoint;
    }
    String swfAccessId = System.getenv("AWS_ACCESS_KEY_ID");
    String swfSecretKey = System.getenv("AWS_SECRET_ACCESS_KEY");

    /*@Autowired
    TempActivities tempActivitiesImpl;*/
    @Autowired
    TempWorkflow tempWorkflowImpl;
    @Bean
    @Scope("workflow")
    public ClientConfiguration clientConfiguration() {
        ClientConfiguration config = new ClientConfiguration();
        config.withSocketTimeout(70 * 1000);
        return config;
    }
    @Bean
    @Scope("workflow")
    public AWSCredentials basicAWSCredentials() {
        BasicAWSCredentials basicAWSCredentials = new BasicAWSCredentials(swfAccessId, swfSecretKey);
        return basicAWSCredentials;
    }
    @Bean
    @Scope("workflow")
    public AmazonSimpleWorkflow amazonSimpleWorkflowClient() {
        AmazonSimpleWorkflow amazonSimpleWorkflowClient = new AmazonSimpleWorkflowClient(basicAWSCredentials(), clientConfiguration());
        amazonSimpleWorkflowClient.setEndpoint(getEndPoint());
        return amazonSimpleWorkflowClient;
    }
    @Bean
    @Scope("workflow")
    public TempActivitiesClient activitiesClientImpl() {
        return new TempActivitiesClientImpl();
    }
    @Bean
    @Scope("workflow")
    public SpringWorkflowWorker springWorkflowWorker() throws InstantiationException, IllegalAccessException {
        SpringWorkflowWorker workflowWorker = new SpringWorkflowWorker(amazonSimpleWorkflowClient(), getDomainName(), getWorkflowTasklistName());

        workflowWorker.addWorkflowImplementation(tempWorkflowImpl);
        workflowWorker.setRegisterDomain(true);
        // workflowWorker.setDomainRetentionPeriodInDays(1);
        return workflowWorker;
    }
    @Bean
    public CustomScopeConfigurer customScope() {
        CustomScopeConfigurer configurer = new CustomScopeConfigurer();
        Map < String, Object > workflowScope = new HashMap < String, Object > ();
        workflowScope.put("workflow", new WorkflowScope());
        configurer.setScopes(workflowScope);

        return configurer;
    }
}
公共类WorkFlowAppConfig{
公共字符串getActivityTasklistName(){
返回“HelloWorldTaskList”;
}
公共字符串getDomainName(){
返回“helloWorldWalkthrough2”;
}
公共字符串getWorkflowTasklistName(){
返回“HelloWorldWorkflow”;
}
公共字符串getEndPoint(){
字符串端点=”https://swf.us-east-1.amazonaws.com";
返回端点;
}
字符串swfAccessId=System.getenv(“AWS_访问键_ID”);
字符串swfSecretKey=System.getenv(“AWS_SECRET_ACCESS_KEY”);
/*@自动连线
临时活动临时活动简单*/
@自动连线
tempWorkflowImpl;
@豆子
@范围(“工作流程”)
public ClientConfiguration ClientConfiguration(){
ClientConfiguration=newclientconfiguration();
使用SocketTimeout配置(70*1000);
返回配置;
}
@豆子
@范围(“工作流程”)
公共AWSCredentials基本凭证(){
BasicAWSCredentials BasicAWSCredentials=新的BasicAWSCredentials(swfAccessId,swfSecretKey);
返回基本凭证;
}
@豆子
@范围(“工作流程”)
公共AmazonSimpleWorkflow amazonSimpleWorkflowClient(){
AmazonSimpleWorkflow amazonSimpleWorkflowClient=新的amazonSimpleWorkflowClient(basicAWSCredentials(),clientConfiguration());
amazonSimpleWorkflowClient.setEndpoint(getEndPoint());
返回amazonSimpleWorkflowClient;
}
@豆子
@范围(“工作流程”)
公共临时活动客户端活动ClientImpl(){
返回新的TempActivitiesClientImpl();
}
@豆子
@范围(“工作流程”)
public SpringWorkflowWorker SpringWorkflowWorker()抛出实例化异常,IllegalAccessException{
SpringWorkflowWorker=新的SpringWorkflowWorker(amazonSimpleWorkflowClient()、getDomainName()、getWorkflowTasklistName());
workflowWorker.addWorkflowImplementation(tempWorkflowImpl);
workflowWorker.setRegisterDomain(true);
//workflowWorker.setDomainRetentionPeriodInDays(1);
返回workflowWorker;
}
@豆子
公共customScope配置器customScope(){
CustomScopeConfigurer configurer=新的CustomScopeConfigurer();
MapworkflowScope=newhashmap();
放置(“工作流”,新workflowScope());
配置器设置范围(工作流范围);
返回配置器;
}
}

您的问题解决了吗?您的问题解决了吗?
public class WorkFlowAppConfig {

    public String getActivityTasklistName() {
        return "HelloWorldTaskList";
    }

    public String getDomainName() {
        return "helloWorldWalkthrough2";
    }

    public String getWorkflowTasklistName() {
        return "HelloWorldWorkflow";
    }
    public String getEndPoint() {
        String endPoint = "https://swf.us-east-1.amazonaws.com";
        return endPoint;
    }
    String swfAccessId = System.getenv("AWS_ACCESS_KEY_ID");
    String swfSecretKey = System.getenv("AWS_SECRET_ACCESS_KEY");

    /*@Autowired
    TempActivities tempActivitiesImpl;*/
    @Autowired
    TempWorkflow tempWorkflowImpl;
    @Bean
    @Scope("workflow")
    public ClientConfiguration clientConfiguration() {
        ClientConfiguration config = new ClientConfiguration();
        config.withSocketTimeout(70 * 1000);
        return config;
    }
    @Bean
    @Scope("workflow")
    public AWSCredentials basicAWSCredentials() {
        BasicAWSCredentials basicAWSCredentials = new BasicAWSCredentials(swfAccessId, swfSecretKey);
        return basicAWSCredentials;
    }
    @Bean
    @Scope("workflow")
    public AmazonSimpleWorkflow amazonSimpleWorkflowClient() {
        AmazonSimpleWorkflow amazonSimpleWorkflowClient = new AmazonSimpleWorkflowClient(basicAWSCredentials(), clientConfiguration());
        amazonSimpleWorkflowClient.setEndpoint(getEndPoint());
        return amazonSimpleWorkflowClient;
    }
    @Bean
    @Scope("workflow")
    public TempActivitiesClient activitiesClientImpl() {
        return new TempActivitiesClientImpl();
    }
    @Bean
    @Scope("workflow")
    public SpringWorkflowWorker springWorkflowWorker() throws InstantiationException, IllegalAccessException {
        SpringWorkflowWorker workflowWorker = new SpringWorkflowWorker(amazonSimpleWorkflowClient(), getDomainName(), getWorkflowTasklistName());

        workflowWorker.addWorkflowImplementation(tempWorkflowImpl);
        workflowWorker.setRegisterDomain(true);
        // workflowWorker.setDomainRetentionPeriodInDays(1);
        return workflowWorker;
    }
    @Bean
    public CustomScopeConfigurer customScope() {
        CustomScopeConfigurer configurer = new CustomScopeConfigurer();
        Map < String, Object > workflowScope = new HashMap < String, Object > ();
        workflowScope.put("workflow", new WorkflowScope());
        configurer.setScopes(workflowScope);

        return configurer;
    }
}