Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
PhilHibbs
Creator II
Creator II

Job introspection

Is it possible for code in a Talend component to be sensitive to the component that it is in - is there any way of writing, for example:

system.out.println( "This component is called " + xxx );

where xxx is some syntax for getting the name of, say, the tJava component that the code is in.

Ideally I'd like to go even further, and put something in an "if" link that looks up the name of the tJob component that is connected to the end of the link.

Labels (3)
8 Replies
Anonymous
Not applicable

Hi,

 

    Could you please advise the use case you are trying to achieve by this activity?

 

    Are you trying to track the job processing state by this methodology? If yes, I would suggest to use Talend AMC or Talend Logserver using ELK which will give better results without disturbing the functionality of a job.

 

Warm Regards,

 

Nikhil Thampi

PhilHibbs
Creator II
Creator II
Author

I want to write some boilerplate code that acts based on where in the job design it is included. Specifically, I want to create a set of context variables that drive the conditional execution of sub-jobs.

So if I have a workflow job that runs Job_A, Job_B and Job_C, I want to have context variables Run_Job_A, Run_Job_B, and Run_Job_C and have a series of "if" links that check the appropriate context variable and use that in the condition.

Hard coded, it would look like this:

"Y".equals(context.Run_Job_A)

To make it dynamic, I would have to move away from context variables and use globalMap, unless the context object can be accessed dynamically. So the dynamic code would look something like this:

"Y".equals(globalMap.get("Run_" + xxx );

where xxx is the code that gets the name of the job that the if link is attached to, or the label of the link itself.

PhilHibbs
Creator II
Creator II
Author

Another way to do this would be to write a Jobscript preprocessor that goes through looking for the placeholder code and fills in the details, then paste the amended Jobscript back into the Talend client...

Anonymous
Not applicable

Hi,

 

    You are right. The second option will be easy to achieve. You can capture the code value and the corresponding level to a DB table which will store his metadata. Based on the current value in the context variable (which in turn is fetched from each stage value assignment), you can steer the if conditions and thereby the program flow.

 

Warm Regards,

 

Nikhil Thampi

PhilHibbs
Creator II
Creator II
Author

I don't understand, what do you mean by "capture the code value"? I don't need to do anything with a database, I just need to get the details of the current component, either the "if" link itself or the components that it is connected to.

Anonymous
Not applicable

Hi,

 

    I was telling that for each stage in a job flow, you can assign some specific value to a context variable. Based on the value of context variable, you can steer the flow accordingly. If you need to capture the various stages for reference, you can capture the details in a reference table.

 

Warm Regards,

 

Nikhil Thampi

PhilHibbs
Creator II
Creator II
Author

But how would the code look up anything in the lookup table? How does it get the information about the current component that it is in? If the answer is that it is not possible, then that's fine.

PhilHibbs
Creator II
Creator II
Author

Looking at the generated Java code, there's a variable called currentComponent. Maybe I could use that. It gives the generated name, such as tJava_5, which is not very useful.I would need some way of converting that name to something meaningful. It looks like the renamed component names are not in the Java code at all, it would be nice if there was a map that returned the renamed name from something like componentLabels.get(currentComponent). And I can't see any way of figuring out which component is at the destination of the if link. Even if I did, it would be the internal name (tRunJob_1) rather than the job name.