Configuring the components for calling the MetaServlet REST Web service to execute a task - 8.0

Data Integration Job Examples

Version
8.0
Language
English
Product
Talend Big Data
Talend Big Data Platform
Talend Data Fabric
Talend Data Integration
Talend Data Management Platform
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Open Studio for Big Data
Talend Open Studio for Data Integration
Talend Open Studio for ESB
Talend Real-Time Big Data Platform
Module
Talend Studio
Content
Design and Development > Designing Jobs
Last publication date
2024-02-06

Procedure

  1. Double-click the tSetGlobalVar component to display its Basic settings view in the Component tab.
  2. Click the [+] button to add a line in the Variables table:
    • In the Key field, type in jsonEncoded

    • In the Value fields, type in:

      MetaServlet.base64Encode("{\"actionName\":\"runTask\",\"taskId\":\"" + context.task_id + "\",\"mode\"
      :\"synchronous\",\"context\":{\"Default\":\"" + ((String)globalMap.get("tMsgBox_1_RESULT")) + "\"},
      \"authPass\":\"" + context.tac_pwd + "\",\"authUser\":\"" + context.tac_user + "\"}") 

      to call the routine you have previously created.

  3. Then double-click the tREST component to display its Basic settings view.
  4. Fill the URL field with the URL of the Web service you are going to invoke. For this use case, type in:
    context.tac_url + "/metaServlet?" +((String)globalMap.get("jsonEncoded"))

    to call the service and encode the MetaServlet parameters in a Json format.

  5. From the HTTP Method list, select GET to send an HTTP request for generating a task.
    In this way, the MetaSerlet is invoked via the REST API of Talend Administration Center with the relevant parameters.
  6. In the Basic settings view of the tLogRow component, select the Basic option to display the result in the Run console.
  7. Save your Job and press F6 to launch it.

Results

The console shows that the tREST component sends an HTTP request to the server end to run the specified task, and that the task has been executed without errors.

Screenshot of the console after successfully running the Job.

In the Job Conductor page of Talend Administration Center, the status of the task is now ready to run.

Screenshot of the Job Conductor page.