http://diethardsteiner.blogspot.in/2012/02/talend-open-studio-how-to-set-up.html
Talend Tutorials:
http://www.talendforge.org/tutorials/tutorial.php?idTuto=34
Environment :
1) TOS 5.1.3
2) Windows 7 OS - Command prompt.
Example Scenario:
Dynamically printing any name that you pass from context variable on console.
This will give you the first basic idea of using context variables in Talend ETL thus you can
implement the same concept for other requirements in your project
What is context variable ? Context variables are user defined variable provided by Talend
Open studio whose value can be changed at run time.
We can provide the values of the context variables at run time which allows jobs to be
executed in different ways with different parameters.
Example:
Find the steps below... For components detailed description, follow the Talend online
Tutorials here at https://help.talend.com/display/HOME/Welcome
PART - I
1) Dragging and dropping components to be use in this job
2) creating context variables
3) Make use of created context variable in "tFixedFlowInput" component.
4) Components usage for this example
5) Executing the job
6) Exporting job and executing from command prompt.
PART - II
1) Exporting Talend JOB
2) Executing the job from command prompt by passing different parameters(i.e., different
context variables).
PART - I
Step 1 : Components in JOB
Drag and drop tFixedFlowInput, tLogRow and tBufferOutput components on to the
design area from palette.
Make "Main" connections in the sequence of components as shown in below figure.
Variables :
1) Click on + Symbol and give the name for your context variable ( In this example context
variable name is "name"
2) Set what type of context variable in your case ( here it is "String"Type)
Note that when you give name, the Script code generates automatically.
Values as tree:
Give default values that you want to pass from context variable .. In this example I given it as
"Sadakar".. at the time of execution from command prompt you can pass any other name lets say
"TalendLearner"..
and the job will take this parameter value and give the same name back on console.
Context variables are user defined variable provided by Talend Open studio whose value
can be changed at run time. We can provide the values of the context variables at runtime
which allows jobs to be executed in different ways with different parameters. For Example,
we can define different context variables for Production & Test and based on the
environment the job is running it will set the variable values. - See more at:
http://www.vikramtakkar.com/2013/01/understand-context-variableswith.html#sthash.rtPUSPQE.dpuf
Context variables are user defined variable provided by Talend Open studio whose value
can be changed at run time. We can provide the values of the context variables at runtime
which allows jobs to be executed in different ways with different parameters. For Example,
we can define different context variables for Production & Test and based on the
environment the job is running it will set the variable values. - See more at:
http://www.vikramtakkar.com/2013/01/understand-context-variableswith.html#sthash.rtPUSPQE.dpuf
Context variables are user defined variable provided by Talend Open studio whose value
can be changed at run time. We can provide the values of the context variables at runtime
which allows jobs to be executed in different ways with different parameters. For Example,
we can define different context variables for Production & Test and based on the
environment the job is running it will set the variable values. - See more at:
http://www.vikramtakkar.com/2013/01/understand-context-variableswith.html#sthash.rtPUSPQE.dpufContext variables are user defined variable provided by
Talend Open studio whose value can be changed at run time. We can provide the values of
the context variables at runtime which allows jobs to be executed in different ways with
different parameters. For Example, we can define different context variables for Production
& Test and based on the environment the job is running it will set the variable values. - See
more at: http://www.vikramtakkar.com/2013/01/understand-context-variableswith.html#sthash.rtPUSPQE.dpufContext variables are user defined variable provided by
Talend Open studio whose value can be changed at run time. We can provide the values of
the context variables at runtime which allows jobs to be executed in different ways with
different parameters. For Example, we can define different context variables for Production
& Test and based on the environment the job is running it will set the variable values. - See
more at: http://www.vikramtakkar.com/2013/01/understand-context-variableswith.html#sthash.rtPUSPQE.dpufContext variables are user defined variable provided by
Talend Open studio whose value can be changed at run time. We can provide the values of
the context variables at runtime which allows jobs to be executed in different ways with
different parameters. For Example, we can define different context variables for Production
& Test and based on the environment the job is running it will set the variable values. - See
more at: http://www.vikramtakkar.com/2013/01/understand-context-variableswith.html#sthash.rtPUSPQE.dpuf
Values as Table:
This will display the values in the form of table.. just for showing all the variables in a neat
format.
You have done with creating context variable.. now you need to make use of this context variable
Step 3:
Making use of created context variable in "fFixedFlowInput" component.
Now, I am going to describe how you can make use of context variable from
tFixedFlowInput
(This a scenario ...)
IDEA is :
Pass any name(a group of characters - in simple lets say a string) from "tFixedFlowInput"
with the help of created context variable and display back the same name on the console
when execute the job from command prompt.
1) Click on "tFixedFlowInput" component
2) Click on Component to get it's properties
3) Click on Edit Schema
4) Click on + sign and give Column name( Any name.. it is not mandatory to give the same
name as context variable) and close it.
5) Give value for the name ( you can type or press Ctrl+Space and then select the context
variable).
Find the image below for flow of steps.
You are done with the make use of context variable which you created in step 3 in
"tFieFixedFlow" component.
i.e., dynamically you are passing name from "tFileFixedFlow" component to get the same
value on the console.
Step 4: other components to view the output
tLogrow:
Displays data or results in the Run console.
Detailed description of this component is
https://help.talend.com/display/TalendComponentsReferenceGuide54EN/tLogRow
tBufferOutput:
This component collects data in a buffer in order to access it later via webservice for example.
Detailed description of this component is
https://help.talend.com/display/TalendComponentsReferenceGuide54EN/tBufferOutput
PART - II
Step 1: Exporting Talend JOB
1) Right click on your job
2) Click on Export job
3) Give the destination for exporting by giving zip file name.
4) Click on finish.
Step 2: Executing Talend JOB from command prompt by passing the parameters.
1) Open command prompt if you use window (This example is based on windows 7 OS).
2) Unzip the exported file and open the open the project using command prompt
Find the image below
Change your directory from the command prompt till you find .bat file of project.
i.e.,
For this example it would be
D:\>Cd C:\Users\helical002\Desktop\test_param_0.1\test_param_0.1\test_param>
Hold on here.....
Open the .bat file in text editor(Notepad++ is preferrable)... You can find a line(s) code
starting with "java"......
for example
java -Xms256M -Xmx1024M -cp classpath.jar;
sadakar_project.test_param_0_1.test_param --context=Default %*
|=-----=|
|Sadakar|
'-------'
Now, Give different names as input from the above command.
Syntax for passing parameters :
--context_param param_1_name=param_1_value param_2_name=param_2_value
In this example lets pass a(differs from default) parameter .. lets say
"context_variable_quick_understanding"
C:\Users\helical002\Desktop\test_param_0.1\test_param_0.1\test_param>java -Xms25
6M -Xmx1024M -cp classpath.jar; sadakar_project.test_param_0_1.test_param -context_param
name=context_variable_quick_understanding
.------------------------------------.
|
tLogRow_1
|
|=----------------------------------=|
|name
|
|=----------------------------------=|
|context_variable_quick_understanding|
'------------------------------------'
That's it... you have done with learning context variables - passing them from command prompt..
NOTE :
When you export your job it will create Default.properties file in your file/folder system.
For example naviage in the folder structure where you can find properties file ( usually it is
under contexts folder
C:\Users\sadakar002\Desktop\test_param_0.1\test_param_0.1\test_param\bitach\test_param_0_1\contex
ts
( Thanks for writing up of "Vikram" , "Dither" on the same for making me to write up this as a quick
learning)....