You are not logged in.

Unanswered posts



Important! This site has been replaced. All content here is read-only. Please visit our brand-new community at https://community.talend.com/. We look forward to hearing from you there!



#1 2009-06-10 10:07:15

nSmolyniec
Member
91 posts

nSmolyniec said:

Pass a context variable value from a child job to a parent job.

Hi everyone,

I have several child jobs for data integration.
One of them is for the rejection of "bad" rows, another for the data I can integrate.
In these two ones, I get the number of inserted rows into context variables.

Now, I would like to pass these context variables to the parent job (before passing them to a child job used for logging).
My first idea was to create the same variable names into the parent job - with no default value - and pick "transmit whole context" for each child job.
However, I get no value when I display my context variables into my console with a "tJava" component (whereas it worked for each child job excuted alone).

What's the correct way to do so ?

Thank you in advance.
Best regards,

Nicolas

Last edited by nSmolyniec (2009-06-10 10:08:11)


T.O.S. Version : 3.0.4
Generated language : Java
O.S. : Win XP SP3

Offline

#2 2009-06-10 21:15:51

bcourtine
Member
64 posts

bcourtine said:

Re: Pass a context variable value from a child job to a parent job.

You can pass context variables from the parent job to a child job but not the contrary.

At the end of your child job, you can send theses informations in a tBufferOutput.

In the parent job, you will get the data in the flow, after the tRunJob. You can then, with a tContextLoad, put theses values in the context, and transmit it to the log job.


Java/J2EE and Talend certified consultant for Alcion Group.

Offline

#3 2009-06-12 15:05:10

nSmolyniec
Member
91 posts

nSmolyniec said:

Re: Pass a context variable value from a child job to a parent job.

Hi bcourtine,

Thanks for your answer wink.
But not really convenient for my use.
So, what's the use of "transmit whole context" ?

Best regards,

Nicolas


T.O.S. Version : 3.0.4
Generated language : Java
O.S. : Win XP SP3

Offline

#4 2009-06-12 20:49:50

bcourtine
Member
64 posts

bcourtine said:

Re: Pass a context variable value from a child job to a parent job.

nSmolyniec wrote:

So, what's the use of "transmit whole context" ?

"Transmit whole context" is used to transmit all the context variables of a parent job to a child job.

If your parent job has 5 context variables but your child job needs only 3, you don't transmit "the whole context" but only the 3 interresting variables.

In every case, context variables are transmitted from parent job to child job. The contrary is not possible.


Java/J2EE and Talend certified consultant for Alcion Group.

Offline

#5 2009-06-15 11:31:34

nSmolyniec
Member
91 posts

nSmolyniec said:

Re: Pass a context variable value from a child job to a parent job.

Hi bcourtine,

Thanks for your answer.
So, there is a mistake in the 3.1.x documentation :

doc wrote:

Tick this box to transfer all the context variables from the child Job to the parent Job.

Best regards,

Nicolas


T.O.S. Version : 3.0.4
Generated language : Java
O.S. : Win XP SP3

Offline

#6 2009-06-15 21:03:21

Volker Brehm
Member
1139 posts

Volker Brehm said:

Re: Pass a context variable value from a child job to a parent job.

Hi Nicolas,

as a workaround you could create a custom static class with a static variable. You could set the variable in your sub job and read it in the main job.

Bye
Volker

Offline

#7 2009-06-16 17:56:14

nSmolyniec
Member
91 posts

nSmolyniec said:

Re: Pass a context variable value from a child job to a parent job.

Hi Volker,

Thanks for your answer.
It is not what I expected but I could be a solution, that's right smile.

Best regards,

Nicolas


T.O.S. Version : 3.0.4
Generated language : Java
O.S. : Win XP SP3

Offline

#8 2009-06-16 19:05:19

JohnGarrettMartin
Member
893 posts

JohnGarrettMartin said:

Re: Pass a context variable value from a child job to a parent job.

heh, one of the strengths of Talend is that, much like Perl, there is always more than one way to do it.

I tend to look at Talend as an ETL programmers assistant rather than an ETL engine. If Talend dosnt make the job easier then using it is a mistake. Luckily for all of us, the vast majority of tasks are simple and easy with Talend.

The thing I see most people forget is that it is very simple to integrate custom code into Talend jobs. This is one of the sources for Talend's flexibility and power-- I highly recommend learning how to use the tJavaFlex (tPerlFlex) component-- it is one of the most useful components in the Talend toolbox.


except, of course, the tLogRow wink

Offline

#9 2009-06-17 08:45:22

nSmolyniec
Member
91 posts

nSmolyniec said:

Re: Pass a context variable value from a child job to a parent job.

Hi John,

Thanks for answering.
However, I can't guess how a "tJavaFlex" component would make it easier to pass a variable from a child job to a parent job.
"tJavaFlex" is useful for data flow. If I want my variable into a data flow, I will have to use some "tBufferOutput" components into the child jobs.
What kind of job do you imagine ?

Best regards,

Nicolas


T.O.S. Version : 3.0.4
Generated language : Java
O.S. : Win XP SP3

Offline

#10 2009-06-17 21:41:21

Volker Brehm
Member
1139 posts

Volker Brehm said:

Re: Pass a context variable value from a child job to a parent job.

Hi together,

I think John you hit the bull's-eye. If you think about Talend do not think about a "graphical interface" to design 100 percent of your job. Think more about creating (easily) a skeleton which you could enrich with more and specialized functionality. Even if in most cases TOS will be flexible and rich of function to allow creating most solutions out of the box.

But like in this special case you reach a point where, from my point of view, in some cases an own solution like a static class is more useful than using the tBufferOutput for example. tBufferOutput is best used for transfering a complete stream from the child to the parent job. But not a simple context variable.

By the way: It may be a good idea to create a feature request about this point.

Bye
Volker

Offline

Board footer

Talend Contributor Agreement - Talend Website Privacy Policy