Search in sources :

Example 1 with ActivityTaskCompletedEventAttributes

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

the class StateMachines method completeActivityTaskByTaskToken.

private static void completeActivityTaskByTaskToken(RequestContext ctx, ActivityTaskData data, RespondActivityTaskCompletedRequest request) {
    ActivityTaskCompletedEventAttributes a = new ActivityTaskCompletedEventAttributes().setIdentity(request.getIdentity()).setScheduledEventId(data.scheduledEventId).setResult(request.getResult()).setIdentity(request.getIdentity()).setStartedEventId(data.startedEventId);
    HistoryEvent event = new HistoryEvent().setEventType(EventType.ActivityTaskCompleted).setActivityTaskCompletedEventAttributes(a);
    ctx.addEvent(event);
}
Also used : ActivityTaskCompletedEventAttributes(com.uber.cadence.ActivityTaskCompletedEventAttributes) HistoryEvent(com.uber.cadence.HistoryEvent)

Example 2 with ActivityTaskCompletedEventAttributes

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

the class StateMachines method completeActivityTaskById.

private static void completeActivityTaskById(RequestContext ctx, ActivityTaskData data, RespondActivityTaskCompletedByIDRequest request) {
    ActivityTaskCompletedEventAttributes a = new ActivityTaskCompletedEventAttributes().setIdentity(request.getIdentity()).setScheduledEventId(data.scheduledEventId).setResult(request.getResult()).setIdentity(request.getIdentity()).setStartedEventId(data.startedEventId);
    HistoryEvent event = new HistoryEvent().setEventType(EventType.ActivityTaskCompleted).setActivityTaskCompletedEventAttributes(a);
    ctx.addEvent(event);
}
Also used : ActivityTaskCompletedEventAttributes(com.uber.cadence.ActivityTaskCompletedEventAttributes) HistoryEvent(com.uber.cadence.HistoryEvent)

Example 3 with ActivityTaskCompletedEventAttributes

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

the class ActivityDecisionContext method handleActivityTaskCompleted.

void handleActivityTaskCompleted(HistoryEvent event) {
    ActivityTaskCompletedEventAttributes attributes = event.getActivityTaskCompletedEventAttributes();
    String activityId = decisions.getActivityId(attributes);
    if (decisions.handleActivityTaskClosed(activityId)) {
        OpenRequestInfo<byte[], ActivityType> scheduled = scheduledActivities.remove(activityId);
        if (scheduled != null) {
            byte[] result = attributes.getResult();
            BiConsumer<byte[], Exception> completionHandle = scheduled.getCompletionCallback();
            completionHandle.accept(result, null);
        }
    }
}
Also used : ActivityTaskCompletedEventAttributes(com.uber.cadence.ActivityTaskCompletedEventAttributes) ActivityType(com.uber.cadence.ActivityType) CancellationException(java.util.concurrent.CancellationException)

Aggregations

ActivityTaskCompletedEventAttributes (com.uber.cadence.ActivityTaskCompletedEventAttributes)3 HistoryEvent (com.uber.cadence.HistoryEvent)2 ActivityType (com.uber.cadence.ActivityType)1 CancellationException (java.util.concurrent.CancellationException)1