Search in sources :

Example 1 with ScheduleActivityTaskDecisionAttributes

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

the class ActivityDecisionContext method scheduleActivityTask.

Consumer<Exception> scheduleActivityTask(ExecuteActivityParameters parameters, BiConsumer<byte[], Exception> callback) {
    final OpenRequestInfo<byte[], ActivityType> context = new OpenRequestInfo<>(parameters.getActivityType());
    final ScheduleActivityTaskDecisionAttributes attributes = new ScheduleActivityTaskDecisionAttributes();
    attributes.setActivityType(parameters.getActivityType());
    attributes.setInput(parameters.getInput());
    if (parameters.getHeartbeatTimeoutSeconds() > 0) {
        attributes.setHeartbeatTimeoutSeconds((int) parameters.getHeartbeatTimeoutSeconds());
    }
    attributes.setScheduleToCloseTimeoutSeconds((int) parameters.getScheduleToCloseTimeoutSeconds());
    attributes.setScheduleToStartTimeoutSeconds((int) parameters.getScheduleToStartTimeoutSeconds());
    attributes.setStartToCloseTimeoutSeconds((int) parameters.getStartToCloseTimeoutSeconds());
    // attributes.setTaskPriority(InternalUtils.taskPriorityToString(parameters.getTaskPriority()));
    String activityId = parameters.getActivityId();
    if (activityId == null) {
        activityId = String.valueOf(decisions.getNextId());
    }
    attributes.setActivityId(activityId);
    String taskList = parameters.getTaskList();
    if (taskList != null && !taskList.isEmpty()) {
        TaskList tl = new TaskList();
        tl.setName(taskList);
        attributes.setTaskList(tl);
    }
    decisions.scheduleActivityTask(attributes);
    context.setCompletionHandle(callback);
    scheduledActivities.put(attributes.getActivityId(), context);
    return new ActivityDecisionContext.ActivityCancellationHandler(attributes.getActivityId(), callback);
}
Also used : TaskList(com.uber.cadence.TaskList) ActivityType(com.uber.cadence.ActivityType) ScheduleActivityTaskDecisionAttributes(com.uber.cadence.ScheduleActivityTaskDecisionAttributes)

Aggregations

ActivityType (com.uber.cadence.ActivityType)1 ScheduleActivityTaskDecisionAttributes (com.uber.cadence.ScheduleActivityTaskDecisionAttributes)1 TaskList (com.uber.cadence.TaskList)1