Search in sources :

Example 1 with SignalExternalWorkflowExecutionInitiatedEventAttributes

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

the class StateMachines method completeExternalSignal.

private static void completeExternalSignal(RequestContext ctx, SignalExternalData data, String runId, long notUsed) {
    SignalExternalWorkflowExecutionInitiatedEventAttributes initiatedEvent = data.initiatedEvent;
    WorkflowExecution signaledExecution = initiatedEvent.getWorkflowExecution().deepCopy().setRunId(runId);
    ExternalWorkflowExecutionSignaledEventAttributes a = new ExternalWorkflowExecutionSignaledEventAttributes().setInitiatedEventId(data.initiatedEventId).setWorkflowExecution(signaledExecution).setControl(initiatedEvent.getControl()).setDomain(initiatedEvent.getDomain());
    HistoryEvent event = new HistoryEvent().setEventType(EventType.ExternalWorkflowExecutionSignaled).setExternalWorkflowExecutionSignaledEventAttributes(a);
    ctx.addEvent(event);
}
Also used : ExternalWorkflowExecutionSignaledEventAttributes(com.uber.cadence.ExternalWorkflowExecutionSignaledEventAttributes) WorkflowExecution(com.uber.cadence.WorkflowExecution) HistoryEvent(com.uber.cadence.HistoryEvent) SignalExternalWorkflowExecutionInitiatedEventAttributes(com.uber.cadence.SignalExternalWorkflowExecutionInitiatedEventAttributes)

Example 2 with SignalExternalWorkflowExecutionInitiatedEventAttributes

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

the class StateMachines method initiateExternalSignal.

private static void initiateExternalSignal(RequestContext ctx, SignalExternalData data, SignalExternalWorkflowExecutionDecisionAttributes d, long decisionTaskCompletedEventId) {
    SignalExternalWorkflowExecutionInitiatedEventAttributes a = new SignalExternalWorkflowExecutionInitiatedEventAttributes();
    a.setDecisionTaskCompletedEventId(decisionTaskCompletedEventId);
    if (d.isSetControl()) {
        a.setControl(d.getControl());
    }
    if (d.isSetInput()) {
        a.setInput(d.getInput());
    }
    if (d.isSetDomain()) {
        a.setDomain(d.getDomain());
    }
    if (d.isSetChildWorkflowOnly()) {
        a.setChildWorkflowOnly(d.isChildWorkflowOnly());
    }
    a.setSignalName(d.getSignalName());
    a.setWorkflowExecution(d.getExecution());
    HistoryEvent event = new HistoryEvent().setEventType(EventType.SignalExternalWorkflowExecutionInitiated).setSignalExternalWorkflowExecutionInitiatedEventAttributes(a);
    long initiatedEventId = ctx.addEvent(event);
    ctx.onCommit((historySize) -> {
        data.initiatedEventId = initiatedEventId;
        data.initiatedEvent = a;
    });
}
Also used : HistoryEvent(com.uber.cadence.HistoryEvent) SignalExternalWorkflowExecutionInitiatedEventAttributes(com.uber.cadence.SignalExternalWorkflowExecutionInitiatedEventAttributes)

Example 3 with SignalExternalWorkflowExecutionInitiatedEventAttributes

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

the class StateMachines method failExternalSignal.

private static void failExternalSignal(RequestContext ctx, SignalExternalData data, SignalExternalWorkflowExecutionFailedCause cause, long notUsed) {
    SignalExternalWorkflowExecutionInitiatedEventAttributes initiatedEvent = data.initiatedEvent;
    SignalExternalWorkflowExecutionFailedEventAttributes a = new SignalExternalWorkflowExecutionFailedEventAttributes().setInitiatedEventId(data.initiatedEventId).setWorkflowExecution(initiatedEvent.getWorkflowExecution()).setControl(initiatedEvent.getControl()).setCause(cause).setDomain(initiatedEvent.getDomain());
    HistoryEvent event = new HistoryEvent().setEventType(EventType.SignalExternalWorkflowExecutionFailed).setSignalExternalWorkflowExecutionFailedEventAttributes(a);
    ctx.addEvent(event);
}
Also used : SignalExternalWorkflowExecutionFailedEventAttributes(com.uber.cadence.SignalExternalWorkflowExecutionFailedEventAttributes) HistoryEvent(com.uber.cadence.HistoryEvent) SignalExternalWorkflowExecutionInitiatedEventAttributes(com.uber.cadence.SignalExternalWorkflowExecutionInitiatedEventAttributes)

Example 4 with SignalExternalWorkflowExecutionInitiatedEventAttributes

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

the class DecisionsHelper method handleSignalExternalWorkflowExecutionInitiated.

void handleSignalExternalWorkflowExecutionInitiated(HistoryEvent event) {
    SignalExternalWorkflowExecutionInitiatedEventAttributes attributes = event.getSignalExternalWorkflowExecutionInitiatedEventAttributes();
    String signalId = new String(attributes.getControl(), StandardCharsets.UTF_8);
    signalInitiatedEventIdToSignalId.put(event.getEventId(), signalId);
    DecisionStateMachine decision = getDecision(new DecisionId(DecisionTarget.SIGNAL, signalId));
    decision.handleInitiatedEvent(event);
}
Also used : SignalExternalWorkflowExecutionInitiatedEventAttributes(com.uber.cadence.SignalExternalWorkflowExecutionInitiatedEventAttributes)

Aggregations

SignalExternalWorkflowExecutionInitiatedEventAttributes (com.uber.cadence.SignalExternalWorkflowExecutionInitiatedEventAttributes)4 HistoryEvent (com.uber.cadence.HistoryEvent)3 ExternalWorkflowExecutionSignaledEventAttributes (com.uber.cadence.ExternalWorkflowExecutionSignaledEventAttributes)1 SignalExternalWorkflowExecutionFailedEventAttributes (com.uber.cadence.SignalExternalWorkflowExecutionFailedEventAttributes)1 WorkflowExecution (com.uber.cadence.WorkflowExecution)1