public WorkflowStatusChecker executeWorkflow()

in flux/src/main/java/software/amazon/aws/clients/swf/flux/RemoteWorkflowExecutorImpl.java [54:98]


    public WorkflowStatusChecker executeWorkflow(Class<? extends Workflow> workflowType, String workflowId,
                                                 Map<String, Object> workflowInput) {
        String workflowName = TaskNaming.workflowName(workflowType);
        if (!workflowsByName.containsKey(workflowName)) {
            throw new WorkflowExecutionException("Cannot execute a workflow that was not provided to Flux at initialization: "
                                                 + workflowName);
        }

        Workflow workflow = workflowsByName.get(workflowName);
        StartWorkflowExecutionRequest request
                = FluxCapacitorImpl.buildStartWorkflowRequest(workflowDomain, workflowName, workflowId,
                                                              workflow.taskList(), workflow.maxStartToCloseDuration(),
                                                              workflowInput);

        log.debug("Requesting new remote workflow execution for workflow {} with id {}", workflowName, workflowId);

        try {
            StartWorkflowExecutionResponse workflowRun = swf.startWorkflowExecution(request);
            log.debug("Started remote workflow {} with id {}: received execution id {}.",
                      workflowName, workflowId, workflowRun.runId());

            return new WorkflowStatusCheckerImpl(swf, workflowDomain, workflowId, workflowRun.runId());
        } catch (WorkflowExecutionAlreadyStartedException e) {
            // swallow, we're ok with this happening
            log.debug("Attempted to start remote workflow {} with id {} but it was already started.",
                      workflowName, workflowId, e);

            // TODO - figure out how to get the execution id in this case, for now just always show an UNKNOWN status.
            return new WorkflowStatusChecker() {
                @Override
                public WorkflowStatus checkStatus() {
                    return WorkflowStatus.UNKNOWN;
                }

                public SwfClient getSwfClient() {
                    return swf;
                }
            };
        } catch (Exception e) {
            String message = String.format("Got exception attempting to start remote workflow %s with id %s",
                                           workflowName, workflowId);
            log.debug(message, e);
            throw new WorkflowExecutionException(message, e);
        }
    }