Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi there
I have a fairly standard job that reads in data from several files, does some transformations and outputs a file. It is all working as it should on my local machine as I define the filepath as absolute paths.
However, I will deploy the project on a server over which I don't have control over the file structure. I would therefore like to create something along the lines of a key-value config/properties file that is packaged with the project. When it is deployed, the variables can be updated to reflect the deployed environment by opening the config file in a text editor, making the changes and saving it. Obviously these variables will need to be read into the job at runtime.
I've read a bit about contexts, but those seem to be defined within the project itself and therefore somebody wouldn't be able to edit the info in there at any time. If they need to change, I would have to make the changes to the context in Talend Studio, build and redeploy. Rather than just opening a text file, making some changes and saving it again.
I assume this is possible. Any pointers in the right direction would be appreciated.
Thanks
yes! it is very much possible. You can place a files in the unix box and store the content as key-value pair with a field delimiter. The key should exactly same as that of your context variable defined in the job.
Content of the file:
DataFilePath=/home/talend/data/
FileName=customer.csv
LogFilePath=home/talend/log
In the Job,
1. Use tInputFileDelimiter component. Provide the absolute file path and file name. Give "=" as the field delimiter and define the schema as string for both key and value fields.
2. Use tContextLoad to load the key value pair.
By this way the value form a file is assigned to context variable during run time.
If you dont want to follow this approach, please follow the suggestions given by TRF. The context variables defined in any talend job is embedded in a property file. when you build the job, along with the wrapper .sh and jar files, there will be a folder named similar to your project name. Under that folder there will be .property files ( by default it would be Default.property) with context variables and its defined values.
Hope this helps!
Regards,
Ragu