Java 类com.amazonaws.services.simpleworkflow.flow.common.WorkflowExecutionUtils 实例源码

项目:WaterFlow    文件:ExamplesIntegrationTest.java   
@Test
public void markerWorkflowTest() {
    //submit workflow
    Workflow<Integer, Integer> workflow = ImmutableSimpleMarkerWorkflow.builder()
            .taskList(config.taskList())
            .executionStartToCloseTimeout(Duration.ofMinutes(5))
            .taskStartToCloseTimeout(Duration.ofSeconds(30))
            .childPolicy(TERMINATE)
            .description(Description.of("A Marker Example Workflow"))
            .dataConverter(config.dataConverter()).build();
    workflowExecution = config.submit(workflow, 100);
    await().ignoreExceptions().pollInterval(1, TimeUnit.SECONDS).atMost(3, TimeUnit.MINUTES).until(() ->
                    getWorkflowExecutionResult(workflowExecution),
            is("201"));
    List<HistoryEvent> historyEvents = WorkflowExecutionUtils.getHistory(config.swf(), config.domain().value(), workflowExecution);
    List<Event> events = Event.fromHistoryEvents(historyEvents);
    List<Event> recordMarkerEvents = events.stream()
            .filter(event -> event.task() == TaskType.RECORD_MARKER).collect(toList());
    assertThat("incorrect number of marker events", recordMarkerEvents, hasSize(1));
    Event recordMarkerEvent = Iterables.getOnlyElement(recordMarkerEvents);
    assertThat(recordMarkerEvent.actionId(), is(SimpleMarkerWorkflow.MARKER_NAME));
    assertThat(recordMarkerEvent.details(), is("101"));
}
项目:WaterFlow    文件:ExamplesIntegrationTest.java   
@Test
public void timerWorkflowTest() {
    //submit workflow
    Workflow<Integer, Integer> workflow = ImmutableTimerWorkflow.builder()
            .taskList(config.taskList())
            .executionStartToCloseTimeout(Duration.ofMinutes(5))
            .taskStartToCloseTimeout(Duration.ofSeconds(30))
            .childPolicy(TERMINATE)
            .description(Description.of("A Timer Example Workflow"))
            .dataConverter(config.dataConverter()).build();
    workflowExecution = config.submit(workflow, 100);
    await().ignoreExceptions().pollInterval(1, TimeUnit.SECONDS).atMost(3, TimeUnit.MINUTES).until(() ->
                    getWorkflowExecutionResult(workflowExecution),
            is("201"));
    List<HistoryEvent> historyEvents = WorkflowExecutionUtils.getHistory(config.swf(), config.domain().value(), workflowExecution);
    List<Event> events = Event.fromHistoryEvents(historyEvents);
    List<Event> timerEvents = events.stream()
            .filter(event -> event.task() == TaskType.TIMER).collect(toList());
    //TimerStarted & TimerFired
    assertThat("incorrect number of marker events", timerEvents, hasSize(2));
    Optional<Event> timerEvent = timerEvents.stream().filter(e -> e.type() == EventType.TimerStarted).findFirst();
    assertThat(timerEvent.get().actionId(), is(TimerWorkflow.TIMER_NAME));
    assertThat(timerEvent.get().control(), is("101"));
}
项目:Camel    文件:CamelActivityImplementation.java   
void throwActivityFailureException(Throwable exception) throws ActivityFailureException, CancellationException {
    if (exception instanceof CancellationException) {
        throw (CancellationException) exception;
    }

    String reason = WorkflowExecutionUtils.truncateReason(exception.getMessage());
    String details = null;
    try {
        details = converter.toData(exception);
    } catch (DataConverterException dataConverterException) {
        if (dataConverterException.getCause() == null) {
            dataConverterException.initCause(exception);
        }
        throw dataConverterException;
    }

    throw new ActivityFailureException(reason, details);
}
项目:Camel    文件:CamelWorkflowDefinition.java   
private void throwWorkflowException(DataConverter c, Throwable exception) throws WorkflowException {
    if (exception instanceof WorkflowException) {
        throw (WorkflowException) exception;
    }
    String reason = WorkflowExecutionUtils.truncateReason(exception.getMessage());
    String details = null;
    try {
        details = c.toData(exception);
    } catch (DataConverterException dataConverterException) {
        if (dataConverterException.getCause() == null) {
            dataConverterException.initCause(exception);
        }
        throw dataConverterException;
    }

    throw new WorkflowException(reason, details);
}
项目: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));
}
项目:WaterFlow    文件:ExamplesIntegrationTest.java   
private static String getWorkflowExecutionResult(WorkflowExecution workflowExecution) {
    return WorkflowExecutionUtils.getWorkflowExecutionResult(config.swf(), config.domain().value(), workflowExecution).getResult();
}
项目:Camel    文件:CamelSWFWorkflowClient.java   
public List<HistoryEvent> getWorkflowExecutionHistory(String workflowId, String runId) {
    return WorkflowExecutionUtils.getHistory(endpoint.getSWClient(),
            configuration.getDomainName(), new WorkflowExecution().withWorkflowId(workflowId).withRunId(runId));
}