简体   繁体   English

如何使用 Talend Open Studio Data Integration 创建属性文件?

[英]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.我曾经使用 Talend Open Integration Studio 来创建作业并从 IDE 运行它或将其导出为可执行的 jar 文件。 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?是否可以创建一个包含不同服务器名称和其他变量的外部配置文件,以便在创建 Talend 作业的可执行 jar 文件后,我可以更改配置文本文件并选择不同的数据库服务器或端口选项?

I also used MuleSoft for a little bit, so if anyone knows how to do this with MuleSoft any advise would be kindly appreciated.我也使用了一点 MuleSoft,所以如果有人知道如何使用 MuleSoft 做到这一点,我们将不胜感激。

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?"根据您问题的内容,我将重新表述主题“如何在 Talend Open Studio 数据集成作业中读取和使用外部属性文件?”

First... create your properties file, "common.properties".首先...创建您的属性文件,“common.properties”。 You could put it in (for example) /etc/classpath, or c:\\etc\\classpath你可以把它放在(例如)/etc/classpath 或 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在 Talend 项目中创建一个公共上下文并将相同的属性添加到上下文

在此处输入图片说明

Create a re-usable job to read the properties and load them.创建一个可重复使用的作业来读取属性并加载它们。 Let's call it Read_ Properties.我们称之为 Read_ 属性。

在此处输入图片说明

Use a tFileInputDelimited component to read the props file.使用 tFileInputDelimited 组件读取道具文件。 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输出应该转到 tBufferOutput

Now... save that reusable job.现在...保存可重复使用的工作。

Create a new job, example_calling_job.创建一个新作业,example_calling_job。
That job should should use the Common context.该作业应该使用 Common 上下文。 That job should have a prejob step, call the properties job with tRunJob, send row output to a tContextLoad该作业应该有一个预作业步骤,使用 tRunJob 调用属性作业,将行输出发送到 tContextLoad

Then, your component in the example_calling_job can use the context variables which were loaded by the property reader job.然后,example_calling_job 中的组件可以使用由属性读取器作业加载的上下文变量。

在此处输入图片说明

Run the example_calling_job.运行 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. tJava 组件写出由属性读取器作业加载到上下文变量中的 context.example_property 值。

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 .使用 Talend,您可以在Context 中定义参数。 You can init a Context with the component tContextLoad .您可以使用组件tContextLoad初始化 Context。

If you are using a standalone job then you can set or override a context value with the command line argument --context_param .如果您使用的是独立作业,则可以使用命令行参数--context_param设置或覆盖上下文值。

You can use tFileOutputProperties to crteate properties file.您可以使用 tFileOutputProperties 来创建属性文件。 Specify the file path of the .properties file in the component settings.在组件设置中指定 .properties 文件的文件路径。

Note that the input schema of the tFileOutputProperties should have only two fields - key and value.请注意,tFileOutputProperties 的输入模式应该只有两个字段 - 键和值。

Similarly, to read from a .properties file, use tFileInputProperties同样,要从 .properties 文件中读取,请使用 tFileInputProperties

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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