Search in sources :

Example 6 with PollForDecisionTaskResponse

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

the class StateMachines method scheduleDecisionTask.

private static void scheduleDecisionTask(RequestContext ctx, DecisionTaskData data, StartWorkflowExecutionRequest request, long notUsed) {
    DecisionTaskScheduledEventAttributes a = new DecisionTaskScheduledEventAttributes().setStartToCloseTimeoutSeconds(request.getTaskStartToCloseTimeoutSeconds()).setTaskList(request.getTaskList()).setAttempt(data.attempt);
    HistoryEvent event = new HistoryEvent().setEventType(EventType.DecisionTaskScheduled).setDecisionTaskScheduledEventAttributes(a);
    long scheduledEventId = ctx.addEvent(event);
    PollForDecisionTaskResponse decisionTaskResponse = new PollForDecisionTaskResponse();
    if (data.previousStartedEventId > 0) {
        decisionTaskResponse.setPreviousStartedEventId(data.previousStartedEventId);
    }
    decisionTaskResponse.setWorkflowExecution(ctx.getExecution());
    decisionTaskResponse.setWorkflowType(request.getWorkflowType());
    decisionTaskResponse.setAttempt(data.attempt);
    TaskListId taskListId = new TaskListId(ctx.getDomain(), request.getTaskList().getName());
    DecisionTask decisionTask = new DecisionTask(taskListId, decisionTaskResponse);
    ctx.setDecisionTask(decisionTask);
    ctx.onCommit((historySize) -> {
        data.scheduledEventId = scheduledEventId;
        data.decisionTask = decisionTaskResponse;
    });
}
Also used : DecisionTask(com.uber.cadence.internal.testservice.TestWorkflowStore.DecisionTask) TaskListId(com.uber.cadence.internal.testservice.TestWorkflowStore.TaskListId) PollForDecisionTaskResponse(com.uber.cadence.PollForDecisionTaskResponse) DecisionTaskScheduledEventAttributes(com.uber.cadence.DecisionTaskScheduledEventAttributes) HistoryEvent(com.uber.cadence.HistoryEvent)

Aggregations

PollForDecisionTaskResponse (com.uber.cadence.PollForDecisionTaskResponse)6 HistoryEvent (com.uber.cadence.HistoryEvent)2 TaskListId (com.uber.cadence.internal.testservice.TestWorkflowStore.TaskListId)2 Decision (com.uber.cadence.Decision)1 DecisionTaskScheduledEventAttributes (com.uber.cadence.DecisionTaskScheduledEventAttributes)1 EntityNotExistsError (com.uber.cadence.EntityNotExistsError)1 InternalServiceError (com.uber.cadence.InternalServiceError)1 PollForActivityTaskResponse (com.uber.cadence.PollForActivityTaskResponse)1 QueryWorkflowResponse (com.uber.cadence.QueryWorkflowResponse)1 RespondDecisionTaskCompletedRequest (com.uber.cadence.RespondDecisionTaskCompletedRequest)1 RespondQueryTaskCompletedRequest (com.uber.cadence.RespondQueryTaskCompletedRequest)1 WorkflowExecution (com.uber.cadence.WorkflowExecution)1 WorkflowType (com.uber.cadence.WorkflowType)1 Timer (com.uber.cadence.internal.testservice.RequestContext.Timer)1 DecisionTask (com.uber.cadence.internal.testservice.TestWorkflowStore.DecisionTask)1 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 ExecutionException (java.util.concurrent.ExecutionException)1 TException (org.apache.thrift.TException)1