How to pass context variable value from TAC to a job?

Five Stars

How to pass context variable value from TAC to a job?

I have 2 jobs setup in TAC, one runs at night and one runs at daytime.    When 1st job runs, it should pass a value 'A' and 2nd job runs, it should pass a value 'I'.  Context variable is called PassRunValue.

Inside both of these two jobs, I've defined the context variable PassRunValue = "A" for job1

and PassRunValue = "I"  for job2.

 

How can we pass the value from TAC to the a job?

 

my job has 

tjava--->if 'A'--->tmssqlinput--->tlogrow

tjava--->if 'I''--->tmssqlinput--->tmssqloutput

 

Currently tjava contains:  context.PassRunValue = "";

Six Stars

Re: How to pass context variable value from TAC to a job?

I don't know how to make that work, if I'm understanding your setup correctly.

 

I have a job that has to run at midnight before some other jobs that run every hour. I have a tJava component that sets the context variable "isMidnight", and I use "run if" links from it to choose a different set of subjobs to run based on the time.

Five Stars

Re: How to pass context variable value from TAC to a job?

Can you show the setup with the screen shot. I'm trying to see how you are setting  context variable "isMidnight".

Six Stars

Re: How to pass context variable value from TAC to a job?

Here's the if logic

runIfSample.PNG

The "InitializeContext" tJava component contains:

ZonedDateTime thisHour = ZonedDateTime.now(ZoneId.of("US/Pacific")).truncatedTo(ChronoUnit.HOURS);
context.isMidnight = thisHour.getHour() == 0;

The "Run if" conditions are then just simply "context.isMidnight" and "!context.isMidnight". This is the Stackoverflow post with the general approach:

https://stackoverflow.com/questions/24504935/skip-a-component-based-on-condition-in-talend

 

Five Stars

Re: How to pass context variable value from TAC to a job?

I'm trying to understand, when I pass the value for PassRunValue variable from TAC, does it overwrite the value set in tjava?

 

1.  Passing PassRunValue = "A" from TAC

2.  Job has tjava component, which has value of  context.PassRunValue = "";

3.  Would tjava component set the context variable context.PassRunValue = "A" ?

 

 

 

 

 

 

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Downloads and Trials

Test drive Talend's enterprise products.

Downloads