Search in sources :

Example 1 with RespondActivityTaskCanceledByIDRequest

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

the class ManualActivityCompletionClientImpl method reportCancellation.

@Override
public void reportCancellation(Object details) {
    if (taskToken != null) {
        RespondActivityTaskCanceledRequest request = new RespondActivityTaskCanceledRequest();
        request.setDetails(dataConverter.toData(details));
        request.setTaskToken(taskToken);
        try {
            service.RespondActivityTaskCanceled(request);
        } catch (TException e) {
            // There is nothing that can be done at this point.
            // so let's just ignore.
            log.info("reportCancellation", e);
        }
    } else {
        RespondActivityTaskCanceledByIDRequest request = new RespondActivityTaskCanceledByIDRequest();
        request.setDetails(dataConverter.toData(details));
        request.setDomain(domain);
        request.setWorkflowID(execution.getWorkflowId());
        request.setRunID(execution.getRunId());
        try {
            service.RespondActivityTaskCanceledByID(request);
        } catch (TException e) {
            // There is nothing that can be done at this point.
            // so let's just ignore.
            log.info("reportCancellation", e);
        }
    }
}
Also used : TException(org.apache.thrift.TException) RespondActivityTaskCanceledByIDRequest(com.uber.cadence.RespondActivityTaskCanceledByIDRequest) RespondActivityTaskCanceledRequest(com.uber.cadence.RespondActivityTaskCanceledRequest)

Example 2 with RespondActivityTaskCanceledByIDRequest

use of com.uber.cadence.RespondActivityTaskCanceledByIDRequest 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);
}
Also used : RespondActivityTaskCanceledByIDRequest(com.uber.cadence.RespondActivityTaskCanceledByIDRequest) ActivityTaskCanceledEventAttributes(com.uber.cadence.ActivityTaskCanceledEventAttributes) HistoryEvent(com.uber.cadence.HistoryEvent) RespondActivityTaskCanceledRequest(com.uber.cadence.RespondActivityTaskCanceledRequest)

Aggregations

RespondActivityTaskCanceledByIDRequest (com.uber.cadence.RespondActivityTaskCanceledByIDRequest)2 RespondActivityTaskCanceledRequest (com.uber.cadence.RespondActivityTaskCanceledRequest)2 ActivityTaskCanceledEventAttributes (com.uber.cadence.ActivityTaskCanceledEventAttributes)1 HistoryEvent (com.uber.cadence.HistoryEvent)1 TException (org.apache.thrift.TException)1