Search in sources :

Example 1 with ChildWorkflowExecutionCanceledEventAttributes

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

the class WorkflowDecisionContext method handleChildWorkflowExecutionCanceled.

void handleChildWorkflowExecutionCanceled(HistoryEvent event) {
    ChildWorkflowExecutionCanceledEventAttributes attributes = event.getChildWorkflowExecutionCanceledEventAttributes();
    WorkflowExecution execution = attributes.getWorkflowExecution();
    String workflowId = execution.getWorkflowId();
    if (decisions.handleChildWorkflowExecutionCanceled(workflowId)) {
        OpenChildWorkflowRequestInfo scheduled = scheduledExternalWorkflows.remove(workflowId);
        if (scheduled != null) {
            CancellationException e = new CancellationException();
            BiConsumer<byte[], Exception> completionCallback = scheduled.getCompletionCallback();
            completionCallback.accept(null, e);
        }
    }
}
Also used : CancellationException(java.util.concurrent.CancellationException) WorkflowExecution(com.uber.cadence.WorkflowExecution) ChildWorkflowExecutionCanceledEventAttributes(com.uber.cadence.ChildWorkflowExecutionCanceledEventAttributes) StartChildWorkflowFailedException(com.uber.cadence.workflow.StartChildWorkflowFailedException) ChildWorkflowTerminatedException(com.uber.cadence.workflow.ChildWorkflowTerminatedException) CancellationException(java.util.concurrent.CancellationException) ChildWorkflowTimedOutException(com.uber.cadence.workflow.ChildWorkflowTimedOutException) SignalExternalWorkflowException(com.uber.cadence.workflow.SignalExternalWorkflowException)

Example 2 with ChildWorkflowExecutionCanceledEventAttributes

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

the class TestWorkflowMutableStateImpl method processCancelWorkflowExecution.

private void processCancelWorkflowExecution(RequestContext ctx, CancelWorkflowExecutionDecisionAttributes d, long decisionTaskCompletedId) throws InternalServiceError {
    workflow.action(StateMachines.Action.CANCEL, ctx, d, decisionTaskCompletedId);
    if (parent.isPresent()) {
        // unlocked by the parent
        ctx.lockTimer();
        ChildWorkflowExecutionCanceledEventAttributes a = new ChildWorkflowExecutionCanceledEventAttributes().setDetails(d.getDetails()).setDomain(ctx.getDomain()).setWorkflowExecution(ctx.getExecution()).setWorkflowType(startRequest.getWorkflowType());
        ForkJoinPool.commonPool().execute(() -> {
            try {
                parent.get().childWorkflowCanceled(ctx.getExecutionId().getWorkflowId().getWorkflowId(), a);
            } catch (EntityNotExistsError entityNotExistsError) {
            // Parent might already close
            } catch (BadRequestError | InternalServiceError e) {
                log.error("Failure reporting child completion", e);
            }
        });
    }
}
Also used : InternalServiceError(com.uber.cadence.InternalServiceError) EntityNotExistsError(com.uber.cadence.EntityNotExistsError) BadRequestError(com.uber.cadence.BadRequestError) ChildWorkflowExecutionCanceledEventAttributes(com.uber.cadence.ChildWorkflowExecutionCanceledEventAttributes)

Aggregations

ChildWorkflowExecutionCanceledEventAttributes (com.uber.cadence.ChildWorkflowExecutionCanceledEventAttributes)2 BadRequestError (com.uber.cadence.BadRequestError)1 EntityNotExistsError (com.uber.cadence.EntityNotExistsError)1 InternalServiceError (com.uber.cadence.InternalServiceError)1 WorkflowExecution (com.uber.cadence.WorkflowExecution)1 ChildWorkflowTerminatedException (com.uber.cadence.workflow.ChildWorkflowTerminatedException)1 ChildWorkflowTimedOutException (com.uber.cadence.workflow.ChildWorkflowTimedOutException)1 SignalExternalWorkflowException (com.uber.cadence.workflow.SignalExternalWorkflowException)1 StartChildWorkflowFailedException (com.uber.cadence.workflow.StartChildWorkflowFailedException)1 CancellationException (java.util.concurrent.CancellationException)1