Search in sources :

Example 1 with ActivityTaskTimedOutEventAttributes

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

the class ActivityDecisionContext method handleActivityTaskTimedOut.

void handleActivityTaskTimedOut(HistoryEvent event) {
    ActivityTaskTimedOutEventAttributes attributes = event.getActivityTaskTimedOutEventAttributes();
    String activityId = decisions.getActivityId(attributes);
    if (decisions.handleActivityTaskClosed(activityId)) {
        OpenRequestInfo<byte[], ActivityType> scheduled = scheduledActivities.remove(activityId);
        if (scheduled != null) {
            TimeoutType timeoutType = attributes.getTimeoutType();
            byte[] details = attributes.getDetails();
            ActivityTaskTimeoutException failure = new ActivityTaskTimeoutException(event.getEventId(), scheduled.getUserContext(), activityId, timeoutType, details);
            BiConsumer<byte[], Exception> completionHandle = scheduled.getCompletionCallback();
            completionHandle.accept(null, failure);
        }
    }
}
Also used : ActivityTaskTimedOutEventAttributes(com.uber.cadence.ActivityTaskTimedOutEventAttributes) TimeoutType(com.uber.cadence.TimeoutType) ActivityType(com.uber.cadence.ActivityType) CancellationException(java.util.concurrent.CancellationException)

Example 2 with ActivityTaskTimedOutEventAttributes

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

the class StateMachines method timeoutActivityTask.

private static void timeoutActivityTask(RequestContext ctx, ActivityTaskData data, TimeoutType timeoutType, long notUsed) {
    ActivityTaskTimedOutEventAttributes a = new ActivityTaskTimedOutEventAttributes().setScheduledEventId(data.scheduledEventId).setDetails(data.heartbeatDetails).setTimeoutType(timeoutType).setStartedEventId(data.startedEventId);
    HistoryEvent event = new HistoryEvent().setEventType(EventType.ActivityTaskTimedOut).setActivityTaskTimedOutEventAttributes(a);
    ctx.addEvent(event);
}
Also used : ActivityTaskTimedOutEventAttributes(com.uber.cadence.ActivityTaskTimedOutEventAttributes) HistoryEvent(com.uber.cadence.HistoryEvent)

Aggregations

ActivityTaskTimedOutEventAttributes (com.uber.cadence.ActivityTaskTimedOutEventAttributes)2 ActivityType (com.uber.cadence.ActivityType)1 HistoryEvent (com.uber.cadence.HistoryEvent)1 TimeoutType (com.uber.cadence.TimeoutType)1 CancellationException (java.util.concurrent.CancellationException)1