One Star

Shared connection between parent job and joblet

We have a joblet which uses a database connection shared with the parent jobs. This joblet can be called in multiple places within the parent job.
In 5.1.1, we had a tOracleConnection in the preJob of both the parent job, and the joblet. The connections all have "register a shared DB connection", with the same connection name.
Since upgrading to 5.2.1, this now causes compilation errors, as we can't have more than one preJob in a job.
So I've removed the preJob from the joblet, but they still need the tOracleConnection. Sometimes (but not always) this works. Other times, I get a null pointer exception when trying to use the connection in the joblet - as if the connection had not yet been established. I know the connection has been established, as it is happening in the preJob of the parent. In fact, I've had a job which contains
preJob->tOracleConnection
step1 -> joblet
\
onOK
\
step2 -> joblet

and I'm getting the null pointer exception from the second joblet! The first one is working, and committing to the database.
joblet is
tOracleConnection
tOracleInput
\
INPUT -> tMap -> tOracleOutput -> tOracleCommit (don't close connection)

It's not possible to put an OnSubjobOK link from a tOracleConnection to the INPUT of the joblet, or even to a tFixedFlowInput and then as a lookup to the tMap from the INPUT
It seems to work if I change the joblet to
                           tOracleInput
\
INPUT -> tMap -> tOracleOutput -> tOracleCommit (don't close connection)
\
tOracleConnection -> tFixedFlow -> tMap

but that seems really clunky and I don't like it. Surely there should be a better way to do this.
8 REPLIES
One Star

Re: Shared connection between parent job and joblet

It appears I can join to the first tMap if I make the tFixedFlow the primary input the the tMap, and the joblet INPUT a lookup (with no join condition). Still not particularly nice ...
One Star

Re: Shared connection between parent job and joblet

Now I've discovered that it seems to be running the entire job multiple times. If I have n copies of the joblet in a job, triggering the job causes the entire flow to run n times.
One Star

Re: Shared connection between parent job and joblet

HI Mark,
I am also in the same situation, after migrating the jobs from previous version to 5.2.1 it giving compilation error on tPrejob for joblet. Have you found the solution?
Thanks
Ramesh
One Star

Re: Shared connection between parent job and joblet

The best way to share the connection from parent in a joblet is to use Dynamic Settings where you put the name of the parent connection as tOracleConnection_1 and make sure you tick the box "Use an existing connection" in the Basic settings.
In theory you could use a context parameter to pass the name from parent but it's not working in my version of TIS 5.0.1 and the work-around is
to hard code tOracleConnection_1 into the Code field or
hijack java and put in it something like " + context.connectionName + "
One Star

Re: Shared connection between parent job and joblet

We have a number of jobs using lubod's suggestion that worked in 5.2.2 but on upgrading to 5.6.2 this no longer works and the code can't be generated. Anyone got a solution?
One Star

Re: Shared connection between parent job and joblet

There appears to be a bug in the tOracleOutput component.
One Star

Re: Shared connection between parent job and joblet

Hi Everyone,
We have several jobs in Talend 5.3 which worked with lubod  solution. Whereas same doesn't work after upgrading to Talend 6.1.1?
We get below error:
Parameter (Component List) has a value (XXX) that doesn't exist anymore. Any work around for this issue?
Thanks,
Sri
One Star

Re: Shared connection between parent job and joblet

We had to get a patch from Talend. I believe this issue persisted into vn6. You may need to download he latest version.