As background for this read the article “Exporting a Job script and executing it outside of Talend Studio” at +this link

Prerequisite

First create and test the Talend job from within Talend Open Studio. Use context variables to support different contexts.

When satisfied then export the job script

  1. Right-click the Job you want to build in the Repository view.
  2. Select Build Job to open the [Build Job] dialog box.
  3. In the To archive file field, browse to the directory where you want to save your built Job.
    1. A good practice is to place Talend jobs in <client_sch_dir>\custom\talend
  4. From the build type list, select the Standalone Job.
  5. Select the Extract the zip file check box if you want the archive file to be automatically extracted in the target directory.
  6. Click Finish to validate your changes, complete the build operation and close the dialog box.
  7. A zipped file for the Jobs is created in the defined place.

If the Talend job has the name “MyJob”, then you will at this point be able to run the Talend job from e.g. Windows Explorer by double clicking <client_sch_dir>\custom\talend\MyJob\MyJob_run.bat

If you make changes in Talend Open Studio to the job, repeat all of the above steps again to re-publish the changes.

Running Talend Job using a bat file

Follow these steps

  1. Create a ROB-EX Macro (Functions->Macro->Edit->New)
  2. Add the “RunExternalProgram” macro command. Edit the macro command to read e.g.

    Notice how the value in “program” is relative from the ROB-EX startup directory – this way avoiding to hard code the full path.
  3. The output from a TalendJob will typically be a ROB-EX XML file, so a normal next step of your ROB-EX macro is to call the “XMLImport” macro command.
  4. Important note: the standard cmd.exe does not support UNC paths. If you need to run the Talend Job from a UNC path, then either
    1. Follow the instructions on how to “Directly Running Talend Job without calling a bat file” given below
    2. Or alternatively edit the .bat file to look like this (add the highlighted text). The reason this will work is that the pushd will automatically create a temporary drive letter pointing to the network path of the UNC path.
rem %~d0
rem cd %~dp0
pushd %~dp0
java -Xms256M -Xmx1024M -cp classpath.jar; robextalend.mastermaterialandinventory_0_1.MasterMaterialAndInventory  --context=Default %* 
popd

Directly Running Talend Job without calling a bat file

We have experienced customers not being allowed to run external bat files. In those cases where running the Job as a bat file is not possible, this alternative shows how to directly start the Talend job in an external Java process. I.e. without calling the bat file.

Follow these steps

  1. To avoid having to specify too many parameters, then from within Talend Open studio select “Window->Preferences->Talend->Import->Export->“Add classpath jar in exported jobs” like shown below
  2. Rebuild your Job like described in the prerequisites at the top of this page.
  3. Create a ROB-EX Macro (Functions->Macro->Edit->New)
  4. Add the “RunExternalProgram” macro command. Edit the macro command to read e.g.

    Notice how “java.exe” is the program to start. The parameters to the program is the command line used in the bat file “MyJob_run.bat” as explained above. So you cannot directly copy the example line shown below. This is an example bat file, copy the parameters marked in yellow
%~d0
cd %~dp0
java -Xms256M -Xmx1024M -cp classpath.jar; robextalend.mastermaterialandinventory_0_1.MasterMaterialAndInventory  --context=Default %*

Feedback

Was this helpful?

Yes No
You indicated this topic was not helpful to you ...
Could you please leave a comment telling us why? Thank you!
Thanks for your feedback.

Post your comment on this topic.

Post Comment