diff --git a/java-sdk/src/main/java/com/netflix/conductor/sdk/workflow/executor/WorkflowExecutor.java b/java-sdk/src/main/java/com/netflix/conductor/sdk/workflow/executor/WorkflowExecutor.java index ae75b6c839..9d62cb0524 100644 --- a/java-sdk/src/main/java/com/netflix/conductor/sdk/workflow/executor/WorkflowExecutor.java +++ b/java-sdk/src/main/java/com/netflix/conductor/sdk/workflow/executor/WorkflowExecutor.java @@ -154,36 +154,43 @@ public void initWorkers(String packagesToScan) { annotatedWorkerExecutor.initWorkers(packagesToScan); } - public CompletableFuture executeWorkflow(String name, Integer version, Object input) { - CompletableFuture future = new CompletableFuture<>(); + private String startWorkflow( + String name, Integer version, WorkflowDef workflowDef, Object input) { Map inputMap = objectMapper.convertValue(input, Map.class); StartWorkflowRequest request = new StartWorkflowRequest(); request.setInput(inputMap); request.setName(name); request.setVersion(version); + request.setWorkflowDef(workflowDef); - String workflowId = workflowClient.startWorkflow(request); + return workflowClient.startWorkflow(request); + } + + public String executeWorkflowFuture(String name, Integer version, Object input) { + String workflowId = this.startWorkflow(name, version, null, input); + CompletableFuture future = new CompletableFuture<>(); + runningWorkflowFutures.put(workflowId, future); + return workflowId; + } + + public CompletableFuture executeWorkflow(String name, Integer version, Object input) { + String workflowId = this.startWorkflow(name, version, null, input); + CompletableFuture future = new CompletableFuture<>(); runningWorkflowFutures.put(workflowId, future); return future; } public CompletableFuture executeWorkflow( ConductorWorkflow conductorWorkflow, Object input) { - + String workflowId = + this.startWorkflow( + conductorWorkflow.getName(), + conductorWorkflow.getVersion(), + conductorWorkflow.toWorkflowDef(), + input); CompletableFuture future = new CompletableFuture<>(); - - Map inputMap = objectMapper.convertValue(input, Map.class); - - StartWorkflowRequest request = new StartWorkflowRequest(); - request.setInput(inputMap); - request.setName(conductorWorkflow.getName()); - request.setVersion(conductorWorkflow.getVersion()); - request.setWorkflowDef(conductorWorkflow.toWorkflowDef()); - - String workflowId = workflowClient.startWorkflow(request); runningWorkflowFutures.put(workflowId, future); - return future; }