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

泄露秘密 提交于 2019-12-01 01:01:29

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 ( https://help.talend.com/display/TalendComponentsReferenceGuide54EN/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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!