Search in sources :

Example 1 with ActivityTaskScheduledEventAttributes

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

the class DecisionsHelper method handleActivityTaskScheduled.

boolean handleActivityTaskScheduled(HistoryEvent event) {
    ActivityTaskScheduledEventAttributes attributes = event.getActivityTaskScheduledEventAttributes();
    String activityId = attributes.getActivityId();
    activitySchedulingEventIdToActivityId.put(event.getEventId(), activityId);
    DecisionStateMachine decision = getDecision(new DecisionId(DecisionTarget.ACTIVITY, activityId));
    decision.handleInitiatedEvent(event);
    return decision.isDone();
}
Also used : ActivityTaskScheduledEventAttributes(com.uber.cadence.ActivityTaskScheduledEventAttributes)

Example 2 with ActivityTaskScheduledEventAttributes

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

the class StateMachines method scheduleActivityTask.

private static void scheduleActivityTask(RequestContext ctx, ActivityTaskData data, ScheduleActivityTaskDecisionAttributes d, long decisionTaskCompletedEventId) {
    ActivityTaskScheduledEventAttributes a = new ActivityTaskScheduledEventAttributes().setInput(d.getInput()).setActivityId(d.getActivityId()).setActivityType(d.getActivityType()).setDomain(d.getDomain() == null ? ctx.getDomain() : d.getDomain()).setHeartbeatTimeoutSeconds(d.getHeartbeatTimeoutSeconds()).setScheduleToCloseTimeoutSeconds(d.getScheduleToCloseTimeoutSeconds()).setScheduleToStartTimeoutSeconds(d.getScheduleToStartTimeoutSeconds()).setStartToCloseTimeoutSeconds(d.getStartToCloseTimeoutSeconds()).setTaskList(d.getTaskList()).setDecisionTaskCompletedEventId(decisionTaskCompletedEventId);
    HistoryEvent event = new HistoryEvent().setEventType(EventType.ActivityTaskScheduled).setActivityTaskScheduledEventAttributes(a);
    long scheduledEventId = ctx.addEvent(event);
    PollForActivityTaskResponse taskResponse = new PollForActivityTaskResponse().setActivityType(d.getActivityType()).setWorkflowExecution(ctx.getExecution()).setActivityId(d.getActivityId()).setInput(d.getInput()).setHeartbeatTimeoutSeconds(d.getHeartbeatTimeoutSeconds()).setScheduleToCloseTimeoutSeconds(d.getScheduleToCloseTimeoutSeconds()).setStartToCloseTimeoutSeconds(d.getStartToCloseTimeoutSeconds()).setScheduledTimestamp(ctx.currentTimeInNanoseconds());
    TaskListId taskListId = new TaskListId(ctx.getDomain(), d.getTaskList().getName());
    ActivityTask activityTask = new ActivityTask(taskListId, taskResponse);
    ctx.addActivityTask(activityTask);
    ctx.onCommit((historySize) -> {
        data.scheduledEvent = a;
        data.scheduledEventId = scheduledEventId;
        data.activityTask = taskResponse;
    });
}
Also used : ActivityTaskScheduledEventAttributes(com.uber.cadence.ActivityTaskScheduledEventAttributes) ActivityTask(com.uber.cadence.internal.testservice.TestWorkflowStore.ActivityTask) PollForActivityTaskResponse(com.uber.cadence.PollForActivityTaskResponse) TaskListId(com.uber.cadence.internal.testservice.TestWorkflowStore.TaskListId) HistoryEvent(com.uber.cadence.HistoryEvent)

Aggregations

ActivityTaskScheduledEventAttributes (com.uber.cadence.ActivityTaskScheduledEventAttributes)2 HistoryEvent (com.uber.cadence.HistoryEvent)1 PollForActivityTaskResponse (com.uber.cadence.PollForActivityTaskResponse)1 ActivityTask (com.uber.cadence.internal.testservice.TestWorkflowStore.ActivityTask)1 TaskListId (com.uber.cadence.internal.testservice.TestWorkflowStore.TaskListId)1