Skip to main content Skip to complementary content

Executing a task and returning its status using MetaServlet

In the following scenario, a task is executed using MetaServlet and its status and Job exit codes are returned in the application.

Before you begin

  • An existing task must be created on the Job Conductor page of Talend Administration Center.

  • You need to know the ID of this task (if not, you can use the getTaskIdByName command to retrieve the ID of the task).

Returning the status of a task executed in synchronous mode

Procedure

Use the runTask MetaServlet command to run the execution task.

Example

For example (on Windows):
MetaServletCaller.bat --tac-url=http://localhost:8080/org.talend.administrator/ 
                     --json-params="{'actionName':'runTask','authPass':'admin','authUser':'admin@company.com', 
                     'mode':'synchronous','taskId':'2502'}" --format-output

Example

If the task has been executed successfully, you will get for example:
{
                     'errorStatus':  'NO_ERROR',
                     'execBasicStatus':  'OK',
                     'execDetailedStatus':  'ENDED_OK',
                     'execDetailedStatusLabel':  'Ok',
                     'execRequestId':  '1406816118032_sYHGd',
                     'executionTime': {
                     'millis': 6011,
                     'seconds': 6
                     },
                     'jobExitCode': 0,
                     'returnCode': 0,
                     'status':  'READY_TO_RUN'
                     }
The task status at the end of the execution is Ready to run and the execution status Ended OK as well as the Job exit code 0 indicate that it ended successfully.

Example

If the task has failed, you will get for example:
{
                  'errorStatus':  'JOB_ERROR',
                  'execBasicStatus':  'ERROR',
                  'execDetailedStatus':  'JOB_ERROR',
                  'execDetailedStatusLabel':  'Job ended with error(s)',
                  'execRequestId':  '1406817091606_fVsht',
                  'executionTime': {
                  'millis': 3847,
                  'seconds': 3
                  },
                  'jobExitCode': 1,
                  'returnCode': 0,
                  'status':  'READY_TO_RUN'
                  }
The execution status Job error as well as the Job exit code 1 indicate that an error occurred during the task execution.

Returning the status of a task executed in asynchronous mode

Procedure

  1. Use the runTask MetaServlet command to run the execution task.

    Example

    For example (on Windows):
    MetaServletCaller.bat --tac-url=http://localhost:8080/org.talend.administrator/ 
                         --json-params="{'actionName':'runTask','authPass':'admin','authUser':'admin@company.com', 
                         'mode':'asynchronous','taskId':'2502'}" --format-output

    Example

    You will get for example:
    {
                      'execRequestId':  '1406817216723_97nsV',
                      'executionTime': {
                      'millis': 1069,
                      'seconds': 1
                      },
                      'returnCode': 0
                      }
  2. Execute the command getTaskExecutionStatus to follow the execution state.

    Example

    For example (on Windows):
    MetaServletCaller.bat --tac-url=http://localhost:8080/org.talend.administrator/ 
                         --json-params="{'actionName':'getTaskExecutionStatus','authPass':'admin',
                         'authUser':'admin@company.com','execRequestId': '1406817216723_97nsV'}" --format-output

    Example

    If the task is still running during the request, you will get for example:
    {
                         'execBasicStatus':  'RUNNING',
                         'execDetailedStatus':  'RUNNING',
                         'execDetailedStatusLabel':  'Running...',
                         'executionTime': {
                         'millis': 309,
                         'seconds': 0
                         },
                         'returnCode': 0
                         }
    The task execution status is Running.

    Example

    If the task execution has ended, you will get for example:
    {
                         'execBasicStatus':  'ERROR',
                         'execDetailedStatus':  'JOB_ERROR',
                         'execDetailedStatusLabel':  'Job ended
                         with error(s)',
                         'executionTime': {
                         'millis': 300,
                         'seconds': 0
                         },
                         'jobExitCode': 1,
                         'returnCode': 0
                         }
    The execution status Job error as well as the Job exit code 1 indicate that an error occurred during the task execution.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!