简体   繁体   中英

How can a properties file be created using Talend Open Studio Data Integration?

I've used Talend Open Integration studio for sometime to just create jobs and run it from the IDE or export it as executable jar file. But I haven't used it extensively. Is it possible to create an external configuration file that holds different server names and other variables so that after I create an executable jar file of my Talend job, I can just change configuration text file and select different database servers or port options?

I also used MuleSoft for a little bit, so if anyone knows how to do this with MuleSoft any advise would be kindly appreciated.

From the content of your question, I would rephrase the subject "How can an external properties file be read and used in a Talend Open Studio Data Integration job?"

First... create your properties file, "common.properties". You could put it in (for example) /etc/classpath, or c:\\etc\\classpath

Example content for property file

example_property="This is an example property"

Create a common context in the Talend Project and add the same properties to the context

在此处输入图片说明

Create a re-usable job to read the properties and load them. Let's call it Read_ Properties.

在此处输入图片说明

Use a tFileInputDelimited component to read the props file. It should use "=" as the row separator.

在此处输入图片说明

It should have a schema with two columns

key, string 
value, string

The output should go to a tBufferOutput

Now... save that reusable job.

Create a new job, example_calling_job.
That job should should use the Common context. That job should have a prejob step, call the properties job with tRunJob, send row output to a tContextLoad

Then, your component in the example_calling_job can use the context variables which were loaded by the property reader job.

在此处输入图片说明

Run the example_calling_job. The tJava component writes out the context.example_property value, which was loaded by the property reader job into the context variable.

Starting job example_calling_job at 11:35 02/03/2016.

[statistics] connecting to socket on port 3497
[statistics] connected
This is an example property.
[statistics] disconnected
Job example_calling_job ended at 11:35 02/03/2016. [exit code=0]

With Talend, you define your parameters in a Context . You can init a Context with the component tContextLoad .

If you are using a standalone job then you can set or override a context value with the command line argument --context_param .

You can use tFileOutputProperties to crteate properties file. Specify the file path of the .properties file in the component settings.

Note that the input schema of the tFileOutputProperties should have only two fields - key and value.

Similarly, to read from a .properties file, use tFileInputProperties

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM