conductor icon indicating copy to clipboard operation
conductor copied to clipboard

How to define inputParams of WorkflowTask?

Open smkb80 opened this issue 9 years ago • 1 comments

Hi Team,

I am trying the conductor-client APIs to create a sample workflow comprising of 2 tasks. I am able to create the tasks, workflow and execute the workflow. But I am facing issue in data transfer between the tasks or accepting workflow input as input in a task. Created and registered a TaskDef as follows:

List<TaskDef> taskDefs = new LinkedList<TaskDef>(); TaskDef taskDef2 = new TaskDef(); taskDef2.setName("Sameek_task2"); taskDef2.setTimeoutPolicy(TimeoutPolicy.TIME_OUT_WF); taskDef2.setTimeoutSeconds(60); List<String> inputParams = new LinkedList<String>(); inputParams.add("outputKey1"); taskDef2.setInputKeys(inputParams); taskDefs.add(taskDef2); TaskClient taskClient = new TaskClient(); taskClient.registerTaskDefs(taskDefs);

Now I am trying to create and register the corresponding WorkFlowTask:

LinkedList<WorkflowTask> tasks = new LinkedList<WorkflowTask>(); WorkflowTask task2 = new WorkflowTask(); task2.setName("Sameek_task2"); task2.setTaskReferenceName("Sameek_task2"); Map<String, Object> inputParamMap = new HashMap<String, Object>(); inputParamMap.put("outputKey1",); /*Not Sure about the second parameter which I want to be an workflow run time input or an output from an previous task*/ task2.setInputParameters(inputParamMap); tasks.add(task2); WorkflowDef def = new WorkflowDef(); def.setTasks(tasks);

As mentioned in the second snippet I am not sure about the second param of the Input Parameters Map which will define the task input key as an runtime input of the workflow/output of a previous task.

I have gone through the WorkflowTask code and the comment just above the declaration of inputParameters says:

//Key: Name of the input parameter. MUST be one of the keys defined in TaskDef (e.g. fileName) //Value: mapping of the parameter from another task (e.g. task1.someOutputParameterAsFileName)

No idea what the comment means specially the value. Also not much document around this in the internet.

Pls help.

smkb80 avatar Mar 22 '17 07:03 smkb80

Just passing workflow.input.paramName as a String object to the inputParamMap worked for me. If previous task output needs to passed as input to the next task, we have to pass previous_task_name.output.paramName to inputParamMap

Sorry for bothering.

smkb80 avatar Mar 22 '17 09:03 smkb80