Search in sources :

Example 1 with ActivityTaskFailedEventAttributes

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

the class StateMachines method failActivityTaskById.

private static void failActivityTaskById(RequestContext ctx, ActivityTaskData data, RespondActivityTaskFailedByIDRequest request) {
    ActivityTaskFailedEventAttributes a = new ActivityTaskFailedEventAttributes().setIdentity(request.getIdentity()).setScheduledEventId(data.scheduledEventId).setDetails(request.getDetails()).setReason(request.getReason()).setIdentity(request.getIdentity()).setStartedEventId(data.startedEventId);
    HistoryEvent event = new HistoryEvent().setEventType(EventType.ActivityTaskFailed).setActivityTaskFailedEventAttributes(a);
    ctx.addEvent(event);
}
Also used : ActivityTaskFailedEventAttributes(com.uber.cadence.ActivityTaskFailedEventAttributes) HistoryEvent(com.uber.cadence.HistoryEvent)

Example 2 with ActivityTaskFailedEventAttributes

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

the class StateMachines method failActivityTaskByTaskToken.

private static void failActivityTaskByTaskToken(RequestContext ctx, ActivityTaskData data, RespondActivityTaskFailedRequest request) {
    ActivityTaskFailedEventAttributes a = new ActivityTaskFailedEventAttributes().setIdentity(request.getIdentity()).setScheduledEventId(data.scheduledEventId).setDetails(request.getDetails()).setReason(request.getReason()).setIdentity(request.getIdentity()).setStartedEventId(data.startedEventId);
    HistoryEvent event = new HistoryEvent().setEventType(EventType.ActivityTaskFailed).setActivityTaskFailedEventAttributes(a);
    ctx.addEvent(event);
}
Also used : ActivityTaskFailedEventAttributes(com.uber.cadence.ActivityTaskFailedEventAttributes) HistoryEvent(com.uber.cadence.HistoryEvent)

Example 3 with ActivityTaskFailedEventAttributes

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

the class ActivityDecisionContext method handleActivityTaskFailed.

void handleActivityTaskFailed(HistoryEvent event) {
    ActivityTaskFailedEventAttributes attributes = event.getActivityTaskFailedEventAttributes();
    String activityId = decisions.getActivityId(attributes);
    if (decisions.handleActivityTaskClosed(activityId)) {
        OpenRequestInfo<byte[], ActivityType> scheduled = scheduledActivities.remove(activityId);
        if (scheduled != null) {
            String reason = attributes.getReason();
            byte[] details = attributes.getDetails();
            ActivityTaskFailedException failure = new ActivityTaskFailedException(event.getEventId(), scheduled.getUserContext(), activityId, reason, details);
            BiConsumer<byte[], Exception> completionHandle = scheduled.getCompletionCallback();
            completionHandle.accept(null, failure);
        }
    }
}
Also used : ActivityTaskFailedEventAttributes(com.uber.cadence.ActivityTaskFailedEventAttributes) ActivityType(com.uber.cadence.ActivityType) CancellationException(java.util.concurrent.CancellationException)

Aggregations

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