My Talend Job reads XML files, and convert them to CSV files. I created a metadata for Input XML file. How can I run the Job from Eclipse, sending the filename as parameter, and then receive that filename in my job to read the right XML file?

有帮助吗?

解决方案

You should define XML file name as a context parameter. Later you will set it in Java code, which you will run from eclipse. In a context section(as on next image) add a new variable named "myXmlFile".

enter image description here Then in your tFileInputXML in Filename/InputStream field set context.myXmlFile.

Next step is exporting the job. To do it, you should follow this instructions. Export it as "Autonomous Job".

Then in your Java project you should add to the classpath a jar generated after job exporting.

To run the job from Java code you should use the next code, in which you will define a context variable and pass it to talend job:

String args[] = new String[3];

args[0] = "--context=Default";
args[1] = "--context_param";
args[2] = "myXmlFile=/path/to/your/xml/file";

YourTallendJobClassName job = new YourTallendJobClassName ();
job.runJob(args);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top