conductor icon indicating copy to clipboard operation
conductor copied to clipboard

http task output

Open amoolya19 opened this issue 9 years ago • 9 comments

Hi, I was trying a simple hello world example. but i was not able to figure out how to configure the output of the microservices in workflow json. example my wf has only 1 task which will call hello world. this would return a json. Also i was wondering on how to have the inputs mapped to the task and microservices other than sending params through uri.

amoolya19 avatar Apr 03 '17 12:04 amoolya19

@amoolya19 do you want to do an HTTP POST with request body? Take a look at the documentation for http task: https://netflix.github.io/conductor/metadata/systask/#http

v1r3n avatar Apr 04 '17 13:04 v1r3n

Hi @v1r3n ,

i tried to a scenario where output of task1 (HTTP type) is input of task2 (type HTTP). i tried to place input of task1 in body tag for task2. but task2 fails and output json has null in the body.

worflow json

[{
	"name": "test_workflow",
	"description": "test http workflow",
	"version": 1,
	"tasks": [{
		"name": "test_task1",
		"taskReferenceName": "tt0",
		"inputParameters": {
			"http_request": {
				"uri": "http://localhost:8081/2",
				"method": "GET"
			}
		},
		"type": "HTTP"
	},
	
	{
		"name": "test_task1",
		"taskReferenceName": "tt1",
		"inputParameters": {
			"http_request": {
				"uri": "http://localhost:8081/tt1",
				"method": "POST",
				"body" : "${tt0.output.number}"
			}
		},
		"type": "HTTP"
	}
	]
	
	"schemaVersion": 2
}]

output json for task 2

 {
         "taskType": "HTTP",
         "status": "FAILED",
         "inputData": {
            "http_request": {
               "uri": "http://localhost:8081/tt1",
               "method": "POST",
               **"body": null**
            }
         },

am i missing anything here?

plus i am getting output status as 200 in swagger which is wrong i feel as my workflow failed.

amoolya19 avatar Apr 05 '17 12:04 amoolya19

@v1r3n

i also tried with simpler version for workflow where there is only 1 task which is of type http

[{
	"name": "test_workflow",
	"description": "test http workflow",
	"version": 1,
	"tasks": [{
		"name": "test_task1",
		"taskReferenceName": "test_task1",
		"inputParameters": {
			"http_request": {
				"uri": "http://localhost:8081/${workflow.input.number}",
				"method": "GET"
			}
		},
		"type": "HTTP"
	}
	],
	"outputParameters": {
    "number": "${test_task1.output.number}"
  },
	"schemaVersion": 2
}]

and after execution, still the output was null for number. image

output json

{
   "createTime": 1491485286280,
   "updateTime": 1491485286764,
   "status": "COMPLETED",
   "endTime": 1491485286764,
   "workflowId": "4f67725b-3d2f-4366-9ddc-8006e990c90a",
   "tasks": [
      {
         "taskType": "HTTP",
         "status": "COMPLETED",
         "inputData": {
            "http_request": {
               "uri": "http://localhost:8081/2",
               "method": "GET"
            }
         },
         "referenceTaskName": "test_task1",
         "retryCount": 0,
         "seq": 1,
         "pollCount": 0,
         "taskDefName": "test_task1",
         "scheduledTime": 1491485286372,
         "startTime": 1491485286492,
         "endTime": 1491485286583,
         "updateTime": 1491485286583,
         "startDelayInSeconds": 0,
         "retried": false,
         "callbackFromWorker": true,
         "responseTimeoutSeconds": 0,
         "workflowInstanceId": "4f67725b-3d2f-4366-9ddc-8006e990c90a",
         "taskId": "642ed013-0841-45ca-afc5-a9435654f8b6",
         "callbackAfterSeconds": 0,
         "workerId": "DAAMO3",
         "outputData": {
            "response": {
               "headers": {
                  "Transfer-Encoding": [
                     "chunked"
                  ],
                  "Server": [
                     "Apache-Coyote/1.1"
                  ],
                  "Date": [
                     "Thu, 06 Apr 2017 13:28:06 GMT"
                  ],
                  "Content-Type": [
                     "application/json;charset=UTF-8"
                  ]
               },
               "body": {
                  "number": 2
               },
               "statusCode": 200
            }
         },
         "queueWaitTime": 120,
         "taskStatus": "COMPLETED"
      }
   ],
   "input": {
      "number": 2
   },
   "output": {
      "number": null
   },
   "workflowType": "test_workflow",
   "version": 1,
   "schemaVersion": 2,
   "startTime": 1491485286280
}

i dont see any special tags or attributes in task or workflow defs in kitchen sink example. could you let me know if anything is wrong here?

amoolya19 avatar Apr 06 '17 13:04 amoolya19

@amoolya19 the output of the HTTP task is contained in the response field of the output of the task. In your original workflow example, the configuration you have supplied for the second task is:

"body" : "${tt0.output.number}"

If you look at the output of the HTTP task, the number is located atresponse.body.number. You have to use the JSON Path of the field from the outputData parameter to inject the value in another task.

Try modifying the parameter config for tt1 task, as follows:

"body" : "${tt0.output.response.body.number}"

OR below should also work, as it is a valid JSON Path.

"body" : "${tt0.output..number}"

One more thing, outputParameters cannot be configured as part of workflow definition, as it is created/updated as the tasks are getting executed.

v1r3n avatar Apr 06 '17 15:04 v1r3n

@v1r3n,

this worked. actually i had tried this yesterday but not sure why it dint work that time.Any ways thank you for the reply.

amoolya19 avatar Apr 07 '17 06:04 amoolya19

I am facing the same issue - not able to extract value from JSON

Both ${tt0.output.response.body.number} and "${tt0.output..number}" returns null.

where as ${tt0.output.*} returns the whole string. But ${tt0.output.response.*} returns null. Any pointers would help.

sudvarma avatar Jul 03 '18 05:07 sudvarma

@v1r3n

Any pointers would help. Thanks

sudvarma avatar Jul 03 '18 05:07 sudvarma

May be I'm missing out on this point : "One more thing, outputParameters cannot be configured as part of workflow definition, as it is created/updated as the tasks are getting executed."

How else to configure output parameters?

sudvarma avatar Jul 03 '18 08:07 sudvarma

It is working, i was using an old server jar.

sudvarma avatar Jul 04 '18 05:07 sudvarma