conductor服務編排http任務安排
# 文件
http://wiki.ttxit.com/pages/viewpage.action?pageId=25919490
# 編排
1.定義任務:http://localhost:8080/api/metadata/taskdefs
[{
"name": "user_task",
"retryCount": 3,
"timeoutSeconds": 1200,
"inputKeys": [
"type"
],
"outputKeys": [
"id",
"name"
],
"timeoutPolicy": "TIME_OUT_WF",
"retryLogic": "FIXED",
"retryDelaySeconds": 600,
"responseTimeoutSeconds": 3600
},
{
"name": "group_task",
"retryCount": 3,
"timeoutSeconds": 1200,
"inputKeys": [
"id",
"name"
],
"outputKeys": [
"response",
"result"
],
"timeoutPolicy": "TIME_OUT_WF",
"retryLogic": "FIXED",
"retryDelaySeconds": 600,
"responseTimeoutSeconds": 3600
}
]
name 任務型別 唯一
retryCount 任務標記為失敗時嘗試重試的次數 -
retryLogic 重試機制
timeoutSeconds 以毫秒為單位的時間,在此之後,如果在轉換到IN_PROGRESS狀態後未完成任務,則將任務標記為TIMED_OUT 如果設定為0,則不會超時
timeoutPolicy 任務的超時策略
responseTimeoutSeconds 如果大於0,則在此時間之後未更新狀態時,將重新安排任務。當work輪詢任務但由於錯誤/網路故障而無法完成時很有用。 -
outputKeys 任務輸出的鍵集。用於記錄任務的輸出
2.定義工作流:http://localhost:8080/api/metadata/workflow
{
"name": "user_and_group",
"description": "Encodes a file and deploys to CDN",
"version": 1,
"tasks": [
{
"name": "user_task",
"taskReferenceName": "user",
"inputParameters": {
"http_request": {
"method": "POST",
"uri": "http://localhost:8000/user/getUser",
"body": {
"type": "${workflow.input.type}"
}
}
},
"type": "HTTP"
},
{
"name": "group_task",
"taskReferenceName": "group",
"inputParameters": {
"http_request": {
"method": "POST",
"uri": "http://localhost:8010/group/getGroup",
"body": {
"id": "${user.output.response.body.id}",
"name": "${user.output.response.body.name}"
}
}
},
"type": "HTTP"
}
],
"outputParameters": {
"response": "${group.output.response.body.response}",
"result": "${group.output.response.body.result}"
},
"schemaVersion": 2
}
3.任務執行:http://localhost:8080/api/workflow/{workname}
在body中定義引數:
{
"type":"1"
}
4.根據上一步返回的id獲取任務資訊:http://localhost:8080/api/workflow/{workid}:
輸出內容:
{
"output": {
"response": [
"1",
"2",
"3",
"4"
],
"result": "李四gaga"
}
}