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

项目: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();
}
项目:Camel    文件:CamelSWFWorkflowClientTest.java   
@Before
public void setUp() throws Exception {
    configuration = new SWFConfiguration();
    configuration.setDomainName("testDomain");
    swClient = mock(AmazonSimpleWorkflowClient.class);
    configuration.setAmazonSWClient(swClient);
    configuration.setStartWorkflowOptionsParameters(Collections.<String, Object>emptyMap());

    endpoint = new SWFEndpoint();
    endpoint.setConfiguration(configuration);
    clientExternal = mock(DynamicWorkflowClientExternalImpl.class);

    camelSWFWorkflowClient = new CamelSWFWorkflowClient(endpoint, configuration) {
        @Override
        DynamicWorkflowClientExternal getDynamicWorkflowClient(String workflowId, String runId) {
            return clientExternal;
        }
    };
}
项目: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;
}
项目:Camel    文件:SWFEndpoint.java   
private AmazonSimpleWorkflowClient createSWClient() throws Exception {
    AWSCredentials credentials = new BasicAWSCredentials(configuration.getAccessKey(), configuration.getSecretKey());

    ClientConfiguration clientConfiguration = new ClientConfiguration();
    if (!configuration.getClientConfigurationParameters().isEmpty()) {
        setProperties(clientConfiguration, configuration.getClientConfigurationParameters());
    }

    AmazonSimpleWorkflowClient client = new AmazonSimpleWorkflowClient(credentials, clientConfiguration);
    if (!configuration.getSWClientParameters().isEmpty()) {
        setProperties(client, configuration.getSWClientParameters());
    }
    return client;
}
项目:Camel    文件:CamelSWFTestSupport.java   
@Override
protected JndiRegistry createRegistry() throws Exception {
    JndiRegistry registry = super.createRegistry();
    amazonSWClient = mock(AmazonSimpleWorkflowClient.class);
    registry.bind("amazonSWClient", amazonSWClient);
    return registry;
}
项目:wildfly-camel    文件:SWFClientProducer.java   
@Produces
@Singleton
public SWFClientProvider getClientProvider() throws Exception {
    AmazonSimpleWorkflowClient client = SWFUtils.createWorkflowClient();
    if (client != null) {
        SWFUtils.registerDomain(client);
    }
    return new SWFClientProvider(client);
}
项目:wildfly-camel    文件:SWFUtils.java   
public static AmazonSimpleWorkflowClient createWorkflowClient() {
    BasicCredentialsProvider credentials = BasicCredentialsProvider.standard();
    AmazonSimpleWorkflowClient client = !credentials.isValid() ? null : (AmazonSimpleWorkflowClient)
            AmazonSimpleWorkflowClientBuilder.standard()
            .withCredentials(credentials)
            .withRegion("eu-west-1")
            .build();
    return client;
}
项目:Camel    文件:SWFEndpoint.java   
public AmazonSimpleWorkflowClient getSWClient() {
    return configuration.getAmazonSWClient() != null ? configuration.getAmazonSWClient() : amazonSWClient;
}
项目:Camel    文件:SWFConfiguration.java   
public AmazonSimpleWorkflowClient getAmazonSWClient() {
    return amazonSWClient;
}
项目:Camel    文件:SWFConfiguration.java   
/**
 * To use the given AmazonSimpleWorkflowClient as client
 */
public void setAmazonSWClient(AmazonSimpleWorkflowClient amazonSWClient) {
    this.amazonSWClient = amazonSWClient;
}
项目: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;
}
项目:wildfly-camel    文件:SWFClientProducer.java   
SWFClientProvider(AmazonSimpleWorkflowClient client) {
    this.client = client;
}
项目:wildfly-camel    文件:SWFClientProducer.java   
public AmazonSimpleWorkflowClient getClient() {
    return client;
}
项目:wildfly-camel    文件:SWFIntegrationTest.java   
@Test
public void deciderAndWorker() throws Exception {

    AmazonSimpleWorkflowClient swfClient = provider.getClient();
    Assume.assumeNotNull("AWS client not null", swfClient);

    WildFlyCamelContext camelctx = new WildFlyCamelContext();
    camelctx.getNamingContext().bind("swfClient", swfClient);
    camelctx.addRoutes(new RouteBuilder() {
        public void configure() {
            String options = "amazonSWClient=#swfClient&domainName=" + SWFUtils.DOMAIN + "&activityList=swf-alist&workflowList=swf-wlist&version=1.0";

            from("aws-swf://activity?" + options + "&eventName=processActivities")
                .log("FOUND ACTIVITY TASK ${body}")
                .setBody(constant("1"))
                .to("mock:worker");

            from("aws-swf://workflow?" + options + "&eventName=processWorkflows")
                .log("FOUND WORKFLOW TASK ${body}").filter(header(SWFConstants.ACTION).isEqualTo(SWFConstants.EXECUTE_ACTION))
                .to("aws-swf://activity?" + options + "&eventName=processActivities")
                .setBody(constant("Message two"))
                .to("aws-swf://activity?" + options + "&eventName=processActivities")
                .log("SENT ACTIVITY TASK ${body}")
                .to("mock:decider");

            from("direct:start")
                .to("aws-swf://workflow?" + options + "&eventName=processWorkflows")
                .log("SENT WORKFLOW TASK ${body}")
                .to("mock:starter");
        }
    });

    MockEndpoint decider = camelctx.getEndpoint("mock:decider", MockEndpoint.class);
    MockEndpoint worker = camelctx.getEndpoint("mock:worker", MockEndpoint.class);
    MockEndpoint starter = camelctx.getEndpoint("mock:starter", MockEndpoint.class);

    camelctx.start();
    try {
        ProducerTemplate producer = camelctx.createProducerTemplate();
        producer.sendBody("direct:start", "Hello world!");

        starter.expectedMessageCount(1);
        decider.expectedMinimumMessageCount(1);
        worker.expectedMessageCount(2);

        String workflowId = starter.getReceivedExchanges().get(0).getIn().getHeader(SWFConstants.WORKFLOW_ID, String.class);
        Assert.assertNotNull(SWFConstants.WORKFLOW_ID + " not null", workflowId);
        SWFUtils.terminateWorkflowExecution(swfClient, workflowId);

    } finally {
        camelctx.stop();
    }
}
项目:wildfly-camel    文件:SWFUtils.java   
public static void terminateWorkflowExecution(AmazonSimpleWorkflowClient swfClient, String workflowId) {
    TerminateWorkflowExecutionRequest terminateReq = new TerminateWorkflowExecutionRequest()
            .withWorkflowId(workflowId)
            .withDomain(DOMAIN);
    swfClient.terminateWorkflowExecution(terminateReq);
}