Context Load from text file - Can't read the loaded variables

Seven Stars

Context Load from text file - Can't read the loaded variables

So I created this quick job and strangely, even after getting confirmation that the variables have been loaded, I can't seem to read the variables using context.<var_name>. What am I doing wrong?

 

The input file has just one variable 'temp_var' with value set to 'passed' (temp_var=passed). While loading the job, I also see the info in the talend log window (tContextLoad_2 set key "test_var" with value "passed"). Further, I can use the context.containsKey("test_var") construct and it yields 'true' in the Java Node. But the moment I try to run the following command, it fails:

 

System.out.println("Value of var test_var read from context " + context.test_var);

 

Kindly help.

 

Screenshot from 2018-08-10 16-49-20.png


Accepted Solutions
Seven Stars

Re: Context Load from text file - Can't read the loaded variables

So I saw the source code of another job with context variables and found that talend internally manages the context variables using the getProperty method. Used that information and it all worked fine.

System.out.println("Value of var test_var read from context " + (String) context.getProperty("test_var"));

All Replies
Seven Stars

Re: Context Load from text file - Can't read the loaded variables

So I saw the source code of another job with context variables and found that talend internally manages the context variables using the getProperty method. Used that information and it all worked fine.

System.out.println("Value of var test_var read from context " + (String) context.getProperty("test_var"));

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

Definitive Guide to Data Integration

Practical steps to developing your data integration strategy.

Download