Our Work

Calling Talend Job from PHP Application

Updated 1 year, 3 months and 3 days ago

Calling Talend Job from PHP Application

Table of Contents:

1. Create a Talend Job:

1.1 Overview:

Talend allows us to export job script and call it from external java applications like eclipse or Netbeans. This procedure explains how to call a Talend job from PHP application.

1.2 Procedure:

In this article we will create a sample job which will print the two values like name and age on the console.

Here we will create a sample Talend job called CallJobFromPHPApplication with two components like tFixedFlowInput and tJavaRow.


 

Select the export type as Autonomous Job and save as archive file (.zip)

 

2. Create a java application in eclipse :

In eclipse, create a java application with the Project name as ‘PHP2Talend’

 

 

Right-click on the package and create a new java class with the name PHPTest.java to call Talend job.

 

Unzip the CallJobFromPHPApplication job to integrate Talend files into eclipse.

 

Right-click on the project root folder and select Build path, then select the Configure Build path option.

3. Integrate Talend Job into Eclipse:


 


 

In the next window open Libraries tab and click on Add External Jars button to import all the required jar files.

 

3.1 Import libraries into java application:

Import below jar files from the CallJobFromPHPApplication directory.

1. Select calljobfromphpapplication_0_1.jar file from CallJobFromPHPApplication_0.1\CallJobFromPHPApplication directory.

2. Import below jar files from CallJobFromPHPApplication_0.1\lib directory.

  • talend_file_enhanced_20070724.jar

  • userRoutines.jar

  • systemRoutines.jar

 

 

Paste the copied directory into src folder as shown in the picture.


 


 

Open the PHPTest.java class in eclipse and edit it as follows.

 


 

 

Right - click on project root directory and click on export will display a new window, select Java->Runnable JAR File.

3.2 Export runnable jar file:

Select the launch configuration details from the dropdown and browse the export destination as show in the picture.

Now PHP2Talend.jar file has been created successfully.

4. Execute Talend job from command line using jar file:

Command:

>>Java –jar PHP2Talend.jar Java 12

 

5. Execute Talend job from PHP application:

Create a Php file callingTalend.php and edit the contents like below:

$cmd="java -jar C:\jars\PHP2Talend.jar";
$name="PHP";
$age ="10";
exec($cmd." ".$name." ".$age,$output);
print_r($output);
?>

Copy this file under xampp/htdocs directory (Assuming that XAMPP already installed)

 

Go to browser and run callingTalend.php file like below:

 

URL: http://localhost/callingTalend.php

Tags

    No tag results found for this post

Related Posts