use of com.uber.cadence.ActivityTaskCanceledEventAttributes in project cadence-client by uber-java.
the class DecisionsHelper method handleActivityTaskCanceled.
public boolean handleActivityTaskCanceled(HistoryEvent event) {
ActivityTaskCanceledEventAttributes attributes = event.getActivityTaskCanceledEventAttributes();
String activityId = getActivityId(attributes);
DecisionStateMachine decision = getDecision(new DecisionId(DecisionTarget.ACTIVITY, activityId));
decision.handleCancellationEvent();
return decision.isDone();
}
use of com.uber.cadence.ActivityTaskCanceledEventAttributes in project cadence-client by uber-java.
the class StateMachines method reportActivityTaskCancellation.
private static void reportActivityTaskCancellation(RequestContext ctx, ActivityTaskData data, Object request, long notUsed) {
byte[] details = null;
if (request instanceof RespondActivityTaskCanceledRequest) {
details = ((RespondActivityTaskCanceledRequest) request).getDetails();
} else if (request instanceof RespondActivityTaskCanceledByIDRequest) {
details = ((RespondActivityTaskCanceledByIDRequest) request).getDetails();
}
ActivityTaskCanceledEventAttributes a = new ActivityTaskCanceledEventAttributes().setScheduledEventId(data.scheduledEventId).setStartedEventId(data.startedEventId);
if (details != null) {
a.setDetails(details);
}
HistoryEvent event = new HistoryEvent().setEventType(EventType.ActivityTaskCanceled).setActivityTaskCanceledEventAttributes(a);
ctx.addEvent(event);
}
use of com.uber.cadence.ActivityTaskCanceledEventAttributes in project cadence-client by uber-java.
the class ActivityDecisionContext method handleActivityTaskCanceled.
void handleActivityTaskCanceled(HistoryEvent event) {
ActivityTaskCanceledEventAttributes attributes = event.getActivityTaskCanceledEventAttributes();
String activityId = decisions.getActivityId(attributes);
if (decisions.handleActivityTaskCanceled(event)) {
CancellationException e = new CancellationException();
OpenRequestInfo<byte[], ActivityType> scheduled = scheduledActivities.remove(activityId);
if (scheduled != null) {
BiConsumer<byte[], Exception> completionHandle = scheduled.getCompletionCallback();
// It is OK to fail with subclass of CancellationException when cancellation requested.
// It allows passing information about cancellation (details in this case) to the surrounding doCatch block
completionHandle.accept(null, e);
}
}
}
Aggregations