Search in sources :

Example 1 with WorkflowExecutionFailedEventAttributes

use of com.uber.cadence.WorkflowExecutionFailedEventAttributes in project cadence-client by uber-java.

the class StateMachines method failWorkflow.

private static void failWorkflow(RequestContext ctx, WorkflowData data, FailWorkflowExecutionDecisionAttributes d, long decisionTaskCompletedEventId) {
    WorkflowExecutionFailedEventAttributes a = new WorkflowExecutionFailedEventAttributes().setReason(d.getReason()).setDetails(d.getDetails()).setDecisionTaskCompletedEventId(decisionTaskCompletedEventId);
    HistoryEvent event = new HistoryEvent().setEventType(EventType.WorkflowExecutionFailed).setWorkflowExecutionFailedEventAttributes(a);
    ctx.addEvent(event);
}
Also used : StartChildWorkflowExecutionFailedEventAttributes(com.uber.cadence.StartChildWorkflowExecutionFailedEventAttributes) SignalExternalWorkflowExecutionFailedEventAttributes(com.uber.cadence.SignalExternalWorkflowExecutionFailedEventAttributes) WorkflowExecutionFailedEventAttributes(com.uber.cadence.WorkflowExecutionFailedEventAttributes) ChildWorkflowExecutionFailedEventAttributes(com.uber.cadence.ChildWorkflowExecutionFailedEventAttributes) HistoryEvent(com.uber.cadence.HistoryEvent)

Example 2 with WorkflowExecutionFailedEventAttributes

use of com.uber.cadence.WorkflowExecutionFailedEventAttributes in project cadence-client by uber-java.

the class WorkflowExecutionUtils method getResultFromCloseEvent.

private static byte[] getResultFromCloseEvent(WorkflowExecution workflowExecution, Optional<String> workflowType, HistoryEvent closeEvent) {
    if (closeEvent == null) {
        throw new IllegalStateException("Workflow is still running");
    }
    switch(closeEvent.getEventType()) {
        case WorkflowExecutionCompleted:
            return closeEvent.getWorkflowExecutionCompletedEventAttributes().getResult();
        case WorkflowExecutionCanceled:
            byte[] details = closeEvent.getWorkflowExecutionCanceledEventAttributes().getDetails();
            String message = details != null ? new String(details, StandardCharsets.UTF_8) : null;
            throw new CancellationException(message);
        case WorkflowExecutionFailed:
            WorkflowExecutionFailedEventAttributes failed = closeEvent.getWorkflowExecutionFailedEventAttributes();
            throw new WorkflowExecutionFailedException(failed.getReason(), failed.getDetails(), failed.getDecisionTaskCompletedEventId());
        case WorkflowExecutionTerminated:
            WorkflowExecutionTerminatedEventAttributes terminated = closeEvent.getWorkflowExecutionTerminatedEventAttributes();
            throw new WorkflowTerminatedException(workflowExecution, workflowType, terminated.getReason(), terminated.getIdentity(), terminated.getDetails());
        case WorkflowExecutionTimedOut:
            WorkflowExecutionTimedOutEventAttributes timedOut = closeEvent.getWorkflowExecutionTimedOutEventAttributes();
            throw new WorkflowTimedOutException(workflowExecution, workflowType, timedOut.getTimeoutType());
        default:
            throw new RuntimeException("Workflow end state is not completed: " + prettyPrintHistoryEvent(closeEvent));
    }
}
Also used : WorkflowExecutionFailedEventAttributes(com.uber.cadence.WorkflowExecutionFailedEventAttributes) WorkflowTimedOutException(com.uber.cadence.client.WorkflowTimedOutException) WorkflowTerminatedException(com.uber.cadence.client.WorkflowTerminatedException) CancellationException(java.util.concurrent.CancellationException) WorkflowExecutionTerminatedEventAttributes(com.uber.cadence.WorkflowExecutionTerminatedEventAttributes) WorkflowExecutionTimedOutEventAttributes(com.uber.cadence.WorkflowExecutionTimedOutEventAttributes)

Aggregations

WorkflowExecutionFailedEventAttributes (com.uber.cadence.WorkflowExecutionFailedEventAttributes)2 ChildWorkflowExecutionFailedEventAttributes (com.uber.cadence.ChildWorkflowExecutionFailedEventAttributes)1 HistoryEvent (com.uber.cadence.HistoryEvent)1 SignalExternalWorkflowExecutionFailedEventAttributes (com.uber.cadence.SignalExternalWorkflowExecutionFailedEventAttributes)1 StartChildWorkflowExecutionFailedEventAttributes (com.uber.cadence.StartChildWorkflowExecutionFailedEventAttributes)1 WorkflowExecutionTerminatedEventAttributes (com.uber.cadence.WorkflowExecutionTerminatedEventAttributes)1 WorkflowExecutionTimedOutEventAttributes (com.uber.cadence.WorkflowExecutionTimedOutEventAttributes)1 WorkflowTerminatedException (com.uber.cadence.client.WorkflowTerminatedException)1 WorkflowTimedOutException (com.uber.cadence.client.WorkflowTimedOutException)1 CancellationException (java.util.concurrent.CancellationException)1