Simple Tasks or Worker Tasks are implemented by your application and run in a separate environment from Conductor. These tasks talk to the Conductor server via REST/gRPC to poll for tasks and update its status after execution.
1.增加conductor-client-spring
依赖在你的SpringBoot项目里面
<dependency>
<groupId>org.conductoross</groupId>
<artifactId>conductor-client-spring</artifactId>
<version>4.0.1</version>
</dependency>
这里要用4.0.1版本,4.0版本不支持SpringBoot。
2.增加com.netflix.conductor
component scan packages
import org.springframework.boot.autoconfigure.SpringBootApplication;;
import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication
@ComponentScan(basePackages = {"com.netflix.conductor"})
public class MyApp {
}
3.在client项目里面配置application.properties
conductor.client.rootUri=http://localhost:8080/api
4.新建一个SampleWork 实现 Conductor Worker
@Component
public class SampleWorker implements Worker {
@Override
public String getTaskDefName() {
return "sample-worker";
}
@Override
public TaskResult execute(Task task) {
log.info("sample-worker executed {}", task.getWorkflowInstanceId());
return TaskResult.newTaskResult(TaskResult.Status.COMPLETED)
.addOutputData("sample-worker", "successful");
}
}
5.任务管理里面定义Task
{
"name": "sample-worker",
"description": "Edit or extend this sample task. Set the task name to get started",
"retryCount": 3,
"timeoutSeconds": 3600,
"inputKeys": [],
"outputKeys": [],
"timeoutPolicy": "TIME_OUT_WF",
"retryLogic": "FIXED",
"retryDelaySeconds": 60,
"responseTimeoutSeconds": 600,
"inputTemplate": {},
"rateLimitPerFrequency": 0,
"rateLimitFrequencyInSeconds": 1,
"ownerEmail": "xx@qq.com",
"backoffScaleFactor": 1,
"totalTimeoutSeconds": 0,
"enforceSchema": false
}
{
"name": "workflow",
"description": "test Workflow",
"version": 1,
"tasks": [{
"name": "sample-worker",
"taskReferenceName": "sample-worker",
"inputParameters": {},
"type": "SIMPLE"
}],
"outputParameters": {},
"failureWorkflow": "",
"restartable": true,
"workflowStatusListenerEnabled": true,
"ownerEmail": "conductor@example.com",
"timeoutPolicy": "ALERT_ONLY",
"timeoutSeconds": 0,
"variables": {},
"inputTemplate": {}
}
根据接口或者界面触发workflow就可以触发对应的自定义worker了。连接器作为iPaaS平台的核心组件之一,在其中扮演着至关重要的角色。它是一种预构建的组件,用于简化和加速不同应用程序、服务和系统之间的集成,无缝集成到企业的IT生态系统中。连接器的功能:
减低成本、可扩展性、灵活、跨领域协同使得IPAAS能够为企业数字化建设增砖添瓦。