Java 类com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow 实例源码

项目:swf-flow-gradle    文件:GreeterWorker.java   
public static void main(String[] args) throws Exception {
    AmazonSimpleWorkflow service = new AmazonSimpleWorkflowClient();
    service.setEndpoint("https://swf.us-east-1.amazonaws.com");

    String domain = "helloWorldWalkthrough";
    String taskListToPoll = "HelloWorldAsyncList";

    WorkflowWorker wfw = new WorkflowWorker(service, domain, taskListToPoll);
    wfw.setRegisterDomain(true);
    wfw.setDomainRetentionPeriodInDays(1);
    wfw.addWorkflowImplementationType(GreeterWorkflowImpl.class);
    wfw.start();

    ActivityWorker aw = new ActivityWorker(service, domain, taskListToPoll);
    aw.addActivitiesImplementation(new GreeterActivitiesImpl());
    aw.start();

    GreeterWorkflowClientExternalFactory clientFactory = new GreeterWorkflowClientExternalFactoryImpl(service, domain);
    GreeterWorkflowClientExternal client = clientFactory.getClient();
    client.greet();
}
项目:WaterFlow    文件:DecisionTaskIteratorTest.java   
@Test
public void multiplePages(@Mocked AmazonSimpleWorkflow swf) {
    PollForDecisionTaskRequest initialRequest = new PollForDecisionTaskRequest();
    List<HistoryEvent> events = loadHistoryEvents("fixtures/simple_workflow.json");
    int numberOfPages = 4;
    int sizePerPage = (int) Math.ceil( (double) events.size() / numberOfPages);
    List<List<HistoryEvent>> pages = Lists.partition(events, sizePerPage);
    assertThat("partitioned incorrectly", pages, hasSize(numberOfPages));
    DecisionTask initialDecisionTask = new DecisionTask().withTaskToken("xyz")
            .withNextPageToken("1").withEvents(pages.get(0));
    DecisionTaskIterator decisionTaskIterator = new DecisionTaskIterator(swf, initialRequest, initialDecisionTask);
    new Expectations() {{
        swf.pollForDecisionTask(initialRequest);times=(numberOfPages-1);
        returns(new DecisionTask().withTaskToken("abc").withNextPageToken("2").withEvents(pages.get(1)),
                new DecisionTask().withTaskToken("def").withNextPageToken("3").withEvents(pages.get(2)),
                new DecisionTask().withTaskToken("ghi").withEvents(pages.get(3)));
    }};

    assertThat(Lists.newArrayList(decisionTaskIterator), is(events));
}
项目:aws-flow-maven-eclipse-samples    文件:WorkflowExecutionStarter.java   
public static void main(String[] args) throws Exception {
    ConfigHelper configHelper = ConfigHelper.createConfig();
    AmazonSimpleWorkflow swfService = configHelper.createSWFClient();
    String domain = configHelper.getDomain();

    HelloWorldWorkflowClientExternalFactory clientFactory = new HelloWorldWorkflowClientExternalFactoryImpl(swfService,
            domain);
    HelloWorldWorkflowClientExternal workflow = clientFactory.getClient();

    // Start Wrokflow Execution
    workflow.helloWorld("User");

    // WorkflowExecution is available after workflow creation 
    WorkflowExecution workflowExecution = workflow.getWorkflowExecution();
    System.out.println("Started helloWorld workflow with workflowId=\"" + workflowExecution.getWorkflowId()
            + "\" and runId=\"" + workflowExecution.getRunId() + "\"");
}
项目:aws-flow-maven-eclipse-samples    文件:WorkflowExecutionGetState.java   
public static void main(String[] args) throws Exception {
    if (args.length < 2) {
        System.err.println("Usage: java " + WorkflowExecutionGetState.class.getName() + " <workflowId> <runId>");
        System.exit(1);
    }
    ConfigHelper configHelper = ConfigHelper.createConfig();
    AmazonSimpleWorkflow swfService = configHelper.createSWFClient();
    String domain = configHelper.getDomain();


    WorkflowExecution workflowExecution = new WorkflowExecution();
    String workflowId = args[1];
    workflowExecution.setWorkflowId(workflowId);
    String runId = args[2];
    workflowExecution.setRunId(runId);

    GenericWorkflowClientExternal client = new GenericWorkflowClientExternalImpl(swfService, domain);

    String state = client.getWorkflowState(workflowExecution);

    System.out.println("Current state of " + workflowExecution + ":");
    System.out.println(state);
}
项目:aws-flow-maven-eclipse-samples    文件:WorkflowExecutionHistoryPrinter.java   
public static void main(String[] args) throws Exception {
    if (args.length < 2) {
        System.err.println("Usage: java " + WorkflowExecutionHistoryPrinter.class.getName() + " <workflowId> <runId>");
        System.exit(1);
    }
    ConfigHelper configHelper = ConfigHelper.createConfig();
    AmazonSimpleWorkflow swfService = configHelper.createSWFClient();
    String domain = configHelper.getDomain();


    WorkflowExecution workflowExecution = new WorkflowExecution();
    String workflowId = args[0];
    workflowExecution.setWorkflowId(workflowId);
    String runId = args[1];
    workflowExecution.setRunId(runId);
    System.out.println(WorkflowExecutionUtils.prettyPrintHistory(swfService, domain, workflowExecution, true));
}
项目:datamung    文件:DataMungServiceImpl.java   
@Autowired
public DataMungServiceImpl( AmazonSimpleWorkflow swfService,
                            ServiceConfig config )
{
    instanceWorkflowFactory =
        new ExportInstanceWorkflowClientExternalFactoryImpl(
                                                             swfService,
                                                             config.getSwfDomainName() );
    snapshotWorkflowFactory =
        new ExportSnapshotWorkflowClientExternalFactoryImpl(
                                                             swfService,
                                                             config.getSwfDomainName() );

    this.swfService = swfService;
    this.swfDomain = config.getSwfDomainName();
}
项目:WaterFlow    文件:DecisionTaskIterator.java   
public DecisionTaskIterator(AmazonSimpleWorkflow swf, PollForDecisionTaskRequest request,
                            DecisionTask startingResponse) {
    this.swf = swf;
    this.request = request;
    this.nextPageToken = startingResponse.getNextPageToken();
    this.currentPage = Optional.ofNullable(startingResponse.getEvents())
            .map(List::iterator).orElse( Collections.emptyIterator());
    this.isLastPage = this.nextPageToken == null;
}
项目:WaterFlow    文件:Config.java   
@Value.Default
public AmazonSimpleWorkflow swf() {
    //SWF holds the connection for 60 seconds to see if a decision is available
    final Duration DEFAULT_CONNECTION_TIMEOUT = Duration.ofSeconds(60);
    final Duration DEFAULT_SOCKET_TIMEOUT = DEFAULT_CONNECTION_TIMEOUT.plusSeconds(10);
    return new AmazonSimpleWorkflowClient(new DefaultAWSCredentialsProviderChain(),
            new ClientConfiguration().withConnectionTimeout((int) DEFAULT_CONNECTION_TIMEOUT.toMillis())
                    .withSocketTimeout((int) DEFAULT_SOCKET_TIMEOUT.toMillis()));
}
项目:swf-starter    文件:Config.java   
/**
 * Create a new SWF client given the current configuration.
 *
 * @return an AmazonSimpleWorkflow client
 */
AmazonSimpleWorkflow createSWFClient() {
  AWSCredentials credentials = new DefaultAWSCredentialsProviderChain().getCredentials();
  AmazonSimpleWorkflow service =
      new AmazonSimpleWorkflowClient(credentials, new ClientConfiguration().withSocketTimeout(SOCKET_TIMEOUT));
  service.setEndpoint(swfServiceUrl);
  return service;
}
项目:aws-flow-maven-eclipse-samples    文件:HumanTaskConsole.java   
/**
 * @throws IOException
 */
public static void main(String[] args) throws IOException {
    //get task token and result from user 
    String taskToken = getTaskToken();
    String result = getResult();

    //complete the activity task
    AmazonSimpleWorkflow swfService = createSWFClient();
    ManualActivityCompletionClientFactory manualCompletionClientFactory = new ManualActivityCompletionClientFactoryImpl(
            swfService);
    ManualActivityCompletionClient manualCompletionClient = manualCompletionClientFactory.getClient(taskToken);
    manualCompletionClient.complete(result);
}
项目:aws-flow-maven-eclipse-samples    文件:WorkflowExecutionFlowThreadDumper.java   
public static void main(String[] args) throws Exception {
    if (args.length < 3) {
        System.err.println("Usage: java " + WorkflowExecutionFlowThreadDumper.class.getName()
                + "<workflow implementation class> <workflowId> <runId>");
        System.exit(1);
    }
    ConfigHelper configHelper = ConfigHelper.createConfig();
    AmazonSimpleWorkflow swfService = configHelper.createSWFClient();
    String domain = configHelper.getDomain();

    WorkflowExecution workflowExecution = new WorkflowExecution();
    String workflowId = args[1];
    workflowExecution.setWorkflowId(workflowId);
    String runId = args[2];
    workflowExecution.setRunId(runId);

    String implementationTypeName = args[0];
    @SuppressWarnings("unchecked")
    Class<Object> workflowImplementationType = (Class<Object>) Class.forName(implementationTypeName);
    WorkflowReplayer<Object> replayer = new WorkflowReplayer<Object>(swfService, domain, workflowExecution,
            workflowImplementationType);

    System.out.println("Beginning workflow replay for " + workflowExecution);
    try {
        String flowThreadDump = replayer.getAsynchronousThreadDumpAsString();
        System.out.println("Workflow asynchronous thread dump:");
        System.out.println(flowThreadDump);
    }
    catch (WorkflowException e) {
        System.out.println("No asynchronous thread dump available as workflow has failed: " + e);
    }
}
项目:aws-flow-maven-eclipse-samples    文件:WorkflowExecutionReplayer.java   
public static void main(String[] args) throws Exception {
    if (args.length < 3) {
        System.err.println("Usage: java " + WorkflowExecutionReplayer.class.getName()
                + "<workflow implementation class> <workflowId> <runId>");
        System.exit(1);
    }
    ConfigHelper configHelper = ConfigHelper.createConfig();
    AmazonSimpleWorkflow swfService = configHelper.createSWFClient();
    String domain = configHelper.getDomain();

    WorkflowExecution workflowExecution = new WorkflowExecution();
    String workflowId = args[1];
    workflowExecution.setWorkflowId(workflowId);
    String runId = args[2];
    workflowExecution.setRunId(runId);

    String implementationTypeName = args[0];
    @SuppressWarnings("unchecked")
    Class<Object> workflowImplementationType = (Class<Object>) Class.forName(implementationTypeName);
    WorkflowReplayer<Object> replayer = new WorkflowReplayer<Object>(swfService, domain, workflowExecution,
            workflowImplementationType);

    System.out.println("Beginning workflow replay for " + workflowExecution);
    Object workflow = replayer.loadWorkflow();
    System.out.println("Workflow implementation object:");
    System.out.println(workflow);

    System.out.println("Done workflow replay for " + workflowExecution);
}
项目:aws-flow-maven-eclipse-samples    文件:HumanTaskConsole.java   
static AmazonSimpleWorkflow createSWFClient() {
    AWSCredentials awsCredentials = new BasicAWSCredentials("{swfAccessId}", "{swfSecretKey}");
    AmazonSimpleWorkflow client = new AmazonSimpleWorkflowClient(awsCredentials);
    client.setEndpoint("{swfServiceUrl}");
    return client;
}
项目:aws-flow-maven-eclipse-samples    文件:ConfigHelper.java   
public AmazonSimpleWorkflow createSWFClient() {
    AWSCredentials awsCredentials = new BasicAWSCredentials(this.swfAccessId, this.swfSecretKey);
    AmazonSimpleWorkflow client = new AmazonSimpleWorkflowClient(awsCredentials);
    client.setEndpoint(this.swfServiceUrl);
    return client;
}
项目:WaterFlow    文件:ActivityContext.java   
public abstract AmazonSimpleWorkflow service();
项目:WaterFlow    文件:BasePollerPool.java   
public abstract AmazonSimpleWorkflow swf();
项目:WaterFlow    文件:BasePoller.java   
public abstract AmazonSimpleWorkflow swf();
项目:WaterFlow    文件:ActivityInvoker.java   
public abstract AmazonSimpleWorkflow service();