Search in sources :

Example 1 with RespondActivityTaskCompletedRequest

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

the class ManualActivityCompletionClientImpl method complete.

@Override
public void complete(Object result) {
    if (taskToken != null) {
        RespondActivityTaskCompletedRequest request = new RespondActivityTaskCompletedRequest();
        byte[] convertedResult = dataConverter.toData(result);
        request.setResult(convertedResult);
        request.setTaskToken(taskToken);
        try {
            service.RespondActivityTaskCompleted(request);
        } catch (EntityNotExistsError e) {
            throw new ActivityNotExistsException(e);
        } catch (TException e) {
            throw new ActivityCompletionFailureException(e);
        }
    } else {
        if (activityId == null) {
            throw new IllegalArgumentException("Either activity id or task token are required");
        }
        RespondActivityTaskCompletedByIDRequest request = new RespondActivityTaskCompletedByIDRequest();
        request.setActivityID(activityId);
        byte[] convertedResult = dataConverter.toData(result);
        request.setResult(convertedResult);
        request.setDomain(domain);
        request.setWorkflowID(execution.getWorkflowId());
        request.setRunID(execution.getRunId());
        try {
            service.RespondActivityTaskCompletedByID(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) RespondActivityTaskCompletedByIDRequest(com.uber.cadence.RespondActivityTaskCompletedByIDRequest) RespondActivityTaskCompletedRequest(com.uber.cadence.RespondActivityTaskCompletedRequest) ActivityCompletionFailureException(com.uber.cadence.client.ActivityCompletionFailureException) EntityNotExistsError(com.uber.cadence.EntityNotExistsError)

Aggregations

EntityNotExistsError (com.uber.cadence.EntityNotExistsError)1 RespondActivityTaskCompletedByIDRequest (com.uber.cadence.RespondActivityTaskCompletedByIDRequest)1 RespondActivityTaskCompletedRequest (com.uber.cadence.RespondActivityTaskCompletedRequest)1 ActivityCompletionFailureException (com.uber.cadence.client.ActivityCompletionFailureException)1 ActivityNotExistsException (com.uber.cadence.client.ActivityNotExistsException)1 TException (org.apache.thrift.TException)1