public void execute()

in src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/ActivityTaskPoller.java [187:249]


    public void execute(ActivityTask task) throws Exception {
        String output = null;
        ActivityType activityType = task.getActivityType();
        ActivityExecutionContext context = new ActivityExecutionContextImpl(service, domain, task);
        ActivityTypeExecutionOptions executionOptions = null;
        try {
            ActivityImplementation activityImplementation = activityImplementationFactory.getActivityImplementation(activityType);
            if (activityImplementation == null) {
                Iterable<ActivityType> typesToRegister = activityImplementationFactory.getActivityTypesToRegister();
                StringBuilder types = new StringBuilder();
                types.append("[");
                for (ActivityType t : typesToRegister) {
                    if (types.length() > 1) {
                        types.append(", ");
                    }
                    types.append(t);
                }
                types.append("]");
                throw new ActivityFailureException("Activity type \"" + activityType
                        + "\" is not supported by the ActivityWorker. "
                        + "Possible cause is activity type version change without changing task list name. "
                        + "Activity types registered with the worker are: " + types.toString());
            }
            executionOptions = activityImplementation.getExecutionOptions();
            output = activityImplementation.execute(context);
        }
        catch (CancellationException e) {
            respondActivityTaskCanceledWithRetry(task.getTaskToken(), null, executionOptions);
            return;
        }
        catch (ActivityFailureException e) {
            if (log.isErrorEnabled()) {
                log.error("Failure processing activity task with taskId=" + task.getStartedEventId() + ", workflowGenerationId="
                        + task.getWorkflowExecution().getWorkflowId() + ", activity=" + activityType + ", activityInstanceId="
                        + task.getActivityId(), e);
            }
            respondActivityTaskFailedWithRetry(task.getTaskToken(), e.getReason(), e.getDetails(), executionOptions);
            return;
        }
        catch (Exception e) {
            if (log.isErrorEnabled()) {
                log.error("Failure processing activity task with taskId=" + task.getStartedEventId() + ", workflowGenerationId="
                        + task.getWorkflowExecution().getWorkflowId() + ", activity=" + activityType + ", activityInstanceId="
                        + task.getActivityId(), e);
            }
            String reason = e.getMessage();
            StringWriter sw = new StringWriter();
            e.printStackTrace(new PrintWriter(sw));
            String details = sw.toString();
            if (details.length() > MAX_DETAIL_LENGTH) {
                log.warn("Length of details is over maximum input length of 32768. Actual details: " + details +
                        "when processing activity task with taskId=" + task.getStartedEventId() + ", workflowGenerationId="
                        + task.getWorkflowExecution().getWorkflowId() + ", activity=" + activityType + ", activityInstanceId="
                        + task.getActivityId());
                details = details.substring(0, MAX_DETAIL_LENGTH);
            }
            respondActivityTaskFailedWithRetry(task.getTaskToken(), reason, details, executionOptions);
            return;
        }
        if (executionOptions == null || !executionOptions.isManualActivityCompletion()) {
            respondActivityTaskCompletedWithRetry(task.getTaskToken(), output, executionOptions);
        }
    }