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.
Set waitWhileUnknownStatus to true
in synchronous mode if the task can return an intermediate
UNKNOWN status before the final status is available.
For example, set this flag when a synchronous request can return
UNKNOWN before the final
ENDED_OK or JOB_ERROR
status is available.
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','waitWhileUnknownStatus':true}" --format-outputExample
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
},
'exitCode': 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 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
},
'exitCode': 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.