Example of triggering a manual business process code

Summary

Manual task refers to the task submitted to the scheduling system after manual task is selected as the scheduling type when a new task is created. After the manual task is submitted to the scheduling system, it will not run automatically, only when triggered manually. This article will introduce how to use Java SDK or PHP Rest API to trigger manual task execution.

Operation process

1. Create a manual business process and submit it

2. Operation and maintenance center view manual tasks

3. Code triggered manual business process

  • Python
from aliyunsdkcore.client import AcsClient
from aliyunsdkcore.request import CommonRequest
client = AcsClient('******', '******', 'default')

request = CommonRequest()
request.set_accept_format('json')
request.set_domain('dataworks.aliyuncs.com')
request.set_method('POST')
request.set_version('2018-06-01')
request.set_action_name('CreateManualDag')

request.add_query_param("ProjectName", "******") # entry name
request.add_query_param("FlowName", "******") # Business process name
request.add_query_param("Bizdate", "2019-01-13 20:45:09")

request.add_query_param('RegionId', 'cn-beijing') # Set the area according to the location of the project
response = client.do_action(request)
print(str(response, encoding = 'utf-8'))
  • Java
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.dataworks_public.model.v20180601.CreateManualDagRequest;
import com.aliyuncs.dataworks_public.model.v20180601.CreateManualDagResponse;
import com.aliyuncs.http.ProtocolType;
import com.aliyuncs.profile.DefaultProfile;

public class HandOnAction {

    public static void main(String[] args) throws Exception {

        String regionId = "cn-beijing";
        String accessKeyId = "******";
        String secret = "******";

        CreateManualDagRequest request = new CreateManualDagRequest();
        request.setProjectName("******");
        request.setFlowName("******");
        request.setVersion("2018-06-01");
        request.setBizdate("2018-07-28 00:00:00");//The time setting is earlier than the current time
//        request.setDagPara("dagppp=dagvvv"); / / set the parameters of the periodic task
        request.setRegionId("cn-beijing");// The region where the project is located needs to be updated here
//        JsonObject nodePara = new JsonObject();
//        nodePara.addProperty("220168343", "aaaa=bbbb"); / / configure the call and node parameters
//        System.out.println(nodePara.toString());
//        request.setNodePara(nodePara.toString());

        //endpoint is also specified as the regionId parameter
        DefaultProfile.addEndpoint(
                regionId,
                regionId,
                "dataworks-public",
                "dataworks.aliyuncs.com");
        DefaultProfile profile = DefaultProfile.getProfile(
                regionId, accessKeyId, secret); // Fill in the actual regionId, accessKeyid, secret

        IAcsClient client = new DefaultAcsClient(profile);
        request.setProtocol(ProtocolType.HTTP);
        CreateManualDagResponse response = client.getAcsResponse(request); //Call client
        System.out.println(response.getRequestId());
        System.out.println("Return Code:" + response.getReturnCode());
        System.out.println(response.getReturnErrorSolution());
        System.out.println(response.getReturnMessage());
        System.out.println(response.getReturnValue()); //Output response
    }
}

4. Test effect

More reference

Trigger manual business process

CreateManualDag

Tags: Python Java SDK PHP REST

Posted on Wed, 04 Dec 2019 01:27:58 -0800 by kusal