Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
My user has a requirement to be able to execute a job along with a context variable outside of Talend.
What are my design options? Maybe create a simple Web service for the user to execute the job? And if so, what would be the general steps/design?
Any design suggestion that satisfies the requirement would be greatly appreciated.
Thanks
Hi Shong,
I would prefer a Web Service for calling the job.
But after reading the documentation for the Talend Open Studio for ESB product, I do not see a way to pass a context variable value (such as the current month) when calling the job.
Is this your understanding?
Thanks
When you call a job from a web service, you can pass context variables value using tRunJob's "Context param" tab as when the parent is a stand alone job.
Setting the value for the context variable can be realized as for any Talend job using tContextLoad component or simple value assignment (context.myVariable = myValue).
On the other side, passing values to the web service should be achieved using http params when the client calls the service.
Thanks TRF,
I'm not sure we are on the same page in regard to the use case requirement.
Please answer my questions:
TRF: When you call a job from a web service, you can pass context variables value using tRunJob's "Context param" tab as when the parent is a stand alone job.
So, what you are saying is the user has a web service. They call a Talend job (parent stand alone job) and pass a parameter value (e.g. "current_month"). The parent job has a tRunJob component where you add a context variable (Parameters Values) into the "Context param" tab of the tRunJob. So, I add contextTimeframe variable as the parameter, but I want the parameter value to be dynamic (meaning I need the contextTimeframe value to be the value the user passes when calling the job from their web service).
Do I need to create another context variable that is set in the ContextLoad component, where contextTimeframe = newcontext variable?
TRF: Setting the value for the context variable can be realized as for any Talend job using tContextLoad component or simple value assignment (context.myVariable = myValue).
So, is it required to use both the "Context param" tab of the tRunJob and the tContextLoad component to satisfy my use case requirement? If so, how do these two components work together?
Thanks
@elkhounds, things are simplest that it looks like from my previous answer.
You know the "Context param" tab of the tRunJob component is used to define which parameter the parent job or service have to pass to the child job. Parameters column must correspond to context variables defined in the child job. For example you may have a line where the parameter value is Timeframe or contextTimeframe depending on how you called the context variable for the child job.
Also you want a dynamic value for this parameter changing for each call. Of course this is possible!
Where does the value passed by the parent job or service come from is not the problem. In fact it could be a context variable or a global variable, it just depends of where the value you want to pass is stored. If you get it from the http request and store it into a global variable, just reuse this variable into the Values columns of the tRunJob using the following expression:
(String)globalMap.get("timeFrame")
Just change the variable's name as you want.
Conclusion (and it was unclear in my previous answer), you must pass value from parent to child using the Context Param tab where each line corresponds to a context variable defined into the child (names must match) and value is issued from what you want.
This was to clarify the previous post but if your client just want to call your job from the command line or something similar with the possibility to force the value to the timeFrame context variable, just add "--context_param timeFrame=yourValue" as a parameter at the end of the command line and that's all.
Hope this helps.
Are you familiar with Talend Open Studio for ESB product?
If so, would you recommend it for creating a web service that can pass parameter values to a Talend job?
Thanks
Greetings,
I'm still looking for a solution for my use case, which is to:
1) Create a web service/GUI for a user that enables her to select a timeframe (e.g. previous 2 months) from a widget that sets the value of a context variable.
2) Have the web service/GUI call an existing Talend job that loads data by timeframe.
I am a novice in this area (web service/GUI development) and would appreciate suggestions to satisfy this use case.
Thanks
Your ESB service idea is interesting. How long would this job run for? If it is a quick job, then you could put this job inside a Talend service and then pass parameters to the service using simple HTML. You could need to set up the ESB Runtime to do this. However, I would only choose this method if the job is pretty quick.
The duration of the job varies from 3 minutes to 36 minutes (depending if user selects a short or long time frame - e.g. current month or current year).
Since the job is not quick, ESB appears not to be the right method.
Can you suggest other methods?
Thanks