Search in sources :

Example 1 with DecisionTaskStartedEventAttributes

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

the class StateMachines method startDecisionTask.

private static void startDecisionTask(RequestContext ctx, DecisionTaskData data, PollForDecisionTaskRequest request, long notUsed) {
    DecisionTaskStartedEventAttributes a = new DecisionTaskStartedEventAttributes().setIdentity(request.getIdentity()).setScheduledEventId(data.scheduledEventId);
    HistoryEvent event = new HistoryEvent().setEventType(EventType.DecisionTaskStarted).setDecisionTaskStartedEventAttributes(a);
    long startedEventId = ctx.addEvent(event);
    ctx.onCommit((historySize) -> {
        data.decisionTask.setStartedEventId(startedEventId);
        DecisionTaskToken taskToken = new DecisionTaskToken(ctx.getExecutionId(), historySize);
        data.decisionTask.setTaskToken(taskToken.toBytes());
        GetWorkflowExecutionHistoryRequest getRequest = new GetWorkflowExecutionHistoryRequest().setDomain(request.getDomain()).setExecution(ctx.getExecution());
        List<HistoryEvent> events;
        try {
            events = data.store.getWorkflowExecutionHistory(ctx.getExecutionId(), getRequest).getHistory().getEvents();
        } catch (EntityNotExistsError entityNotExistsError) {
            throw new InternalServiceError(entityNotExistsError.toString());
        }
        data.decisionTask.setHistory(new History().setEvents(events));
        data.previousStartedEventId = startedEventId;
        data.attempt++;
    });
}
Also used : DecisionTaskStartedEventAttributes(com.uber.cadence.DecisionTaskStartedEventAttributes) GetWorkflowExecutionHistoryRequest(com.uber.cadence.GetWorkflowExecutionHistoryRequest) InternalServiceError(com.uber.cadence.InternalServiceError) EntityNotExistsError(com.uber.cadence.EntityNotExistsError) HistoryEvent(com.uber.cadence.HistoryEvent) History(com.uber.cadence.History)

Aggregations

DecisionTaskStartedEventAttributes (com.uber.cadence.DecisionTaskStartedEventAttributes)1 EntityNotExistsError (com.uber.cadence.EntityNotExistsError)1 GetWorkflowExecutionHistoryRequest (com.uber.cadence.GetWorkflowExecutionHistoryRequest)1 History (com.uber.cadence.History)1 HistoryEvent (com.uber.cadence.HistoryEvent)1 InternalServiceError (com.uber.cadence.InternalServiceError)1