Search in sources :

Example 1 with RespondActivityTaskFailedByIDRequest

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

the class ManualActivityCompletionClientImpl method fail.

@Override
public void fail(Throwable failure) {
    if (failure == null) {
        throw new IllegalArgumentException("null failure");
    }
    // When converting failures reason is class name, details are serialized exception.
    if (taskToken != null) {
        RespondActivityTaskFailedRequest request = new RespondActivityTaskFailedRequest();
        request.setReason(failure.getClass().getName());
        request.setDetails(dataConverter.toData(failure));
        request.setTaskToken(taskToken);
        try {
            service.RespondActivityTaskFailed(request);
        } catch (EntityNotExistsError e) {
            throw new ActivityNotExistsException(e);
        } catch (TException e) {
            throw new ActivityCompletionFailureException(e);
        }
    } else {
        RespondActivityTaskFailedByIDRequest request = new RespondActivityTaskFailedByIDRequest();
        request.setReason(failure.getClass().getName());
        request.setDetails(dataConverter.toData(failure));
        request.setDomain(domain);
        request.setWorkflowID(execution.getWorkflowId());
        request.setRunID(execution.getRunId());
        try {
            service.RespondActivityTaskFailedByID(request);
        } catch (EntityNotExistsError e) {
            throw new ActivityNotExistsException(e);
        } catch (TException e) {
            throw new ActivityCompletionFailureException(activityId, e);
        }
    }
}
Also used : ActivityNotExistsException(com.uber.cadence.client.ActivityNotExistsException) TException(org.apache.thrift.TException) RespondActivityTaskFailedByIDRequest(com.uber.cadence.RespondActivityTaskFailedByIDRequest) ActivityCompletionFailureException(com.uber.cadence.client.ActivityCompletionFailureException) EntityNotExistsError(com.uber.cadence.EntityNotExistsError) RespondActivityTaskFailedRequest(com.uber.cadence.RespondActivityTaskFailedRequest)

Aggregations

EntityNotExistsError (com.uber.cadence.EntityNotExistsError)1 RespondActivityTaskFailedByIDRequest (com.uber.cadence.RespondActivityTaskFailedByIDRequest)1 RespondActivityTaskFailedRequest (com.uber.cadence.RespondActivityTaskFailedRequest)1 ActivityCompletionFailureException (com.uber.cadence.client.ActivityCompletionFailureException)1 ActivityNotExistsException (com.uber.cadence.client.ActivityNotExistsException)1 TException (org.apache.thrift.TException)1