How to set variable in Route and pass it into cTalendJob in contxtPara

One Star

How to set variable in Route and pass it into cTalendJob in contxtPara

How I can ascribe "exchange.getIn().getMessageId()" to variable and pass it through "ContextParam" in cTalendJob to my Job?  I can pass String like "bla bla bla", but when I try pass variable like ${myVariable}, #{myVariable}, {myVariable}, $myVariable, context.myVariable I get error "myVariable cannot be resolved a variable". Someone knows how to do it?


  
Six Stars

Re: How to set variable in Route and pass it into cTalendJob in contxtPara

Czesc Smiley Wink
if you want to access a contextvariable you need to have it in the context of Job testowyroute already.
better use the globalMap:
in cProcessor1 write : globalMap.put("messid", ......);
in cTalendJob at column wartosci you write: (typeofmessagid)globalMap.get("messid")
HTH
dj
One Star

Re: How to set variable in Route and pass it into cTalendJob in contxtPara

Thx for replay.
I added cProcessor before cTalendJob with this:
import java.util.Map;
Map globalMap = new HashMap();
globalMap.put("messId", "testId");
and in cTalendJob in Context Param this:
(String) globalMap.get("messId")
but I get error "globalMap cannot be resolved". 
Six Stars

Re: How to set variable in Route and pass it into cTalendJob in contxtPara

???
globalMap is a standard Map in the TOS/TIS jobs, no need to declare it.
maybe the ESB architecture/codegeneration differs from TOS.
Sorry, cant help you then
Seven Stars

Re: How to set variable in Route and pass it into cTalendJob in contxtPara

It's much easier than you think. The id is already part of the message. You don't need to change the route at all, instead in your job the first component should be a tRouteInput component. The schema of that component will be by default:
 body -> "${in.body}"
 Edit the schema and add a new column of type string: 
messageId -> "${id}"
Then simply assign it to whatever variable you wish from the flow. 
One Star

Re: How to set variable in Route and pass it into cTalendJob in contxtPara

???
globalMap is a standard Map in the TOS/TIS jobs, no need to declare it.
maybe the ESB architecture/codegeneration differs from TOS.
Sorry, cant help you then

yes for jobs, but it does not exist in routes.

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

An API-First Approach to Modernizing Applications

Learn how to use an API-First Approach to Modernize your Applications

Watch Now

Talend API Designer – Technical Overview

Take a look at this technical overview video of Talend API Designer

Watch Now

Getting Started with APIs

Find out how to get started with APIs

Read