Search code examples
javamulemule-studiotalend

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.


Solution

  • 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

    enter image description here

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

    enter image description here

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

    enter image description here

    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.

    enter image description here

    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]