Six Stars

put a java variable inside the global map

Hello,
I am using an external java libary in talend esb. Inside a ctalendjob I put the variable into the globalmap.
 

Inside the tjava I put the java variable inside the global map:
globalMap.put("javaobject", javaobject);

I call this job in the route:

In an other ctalendjob I want to use this object. But the globalmap ist empty. I use a delay of 10s for waiting the object is created and put it inside the map. Maybe there is a better solution. 
Hope someone can help me.
Greets Benjamin
5 REPLIES
Four Stars

Re: put a java variable inside the global map

You can not use the globalMap from one Job in another by default (the map is global to the Jobs, not to the world )
There are some articles/posts here around, how to pass a globalmap to another  Job, you Need to look what helps you best
You could also pass your Java-object as an Object through the context of your subjob if its one way.
Hth
dj
One Star

Re: put a java variable inside the global map

Hello Benjamin,
You want to get the object that you put in the talend job from the route?
Lin LIN
Consultant BI/Talend
Synaltic Group
Six Stars

Re: put a java variable inside the global map

I want to read files from a directory and start if new files received. For that I use cfile. The files have to parse with a custom parser (I have wrote in java), after parsing I want to delete the files and wait for new files receive. For that I create a java object from the parser (singleton). How can I use that object in an other job of the routine? 
Fifteen Stars

Re: put a java variable inside the global map

You need to pass the value of your globalMap variable out to the route via the tRouteOutput_3. Create and output "Header" and assign it the value of your globalMap. Then in your route, you can interrogate this by acquiring that header. It will be held as an Object so you will need to cast it to the correct type. If you want to simply pass it to the next cTalendJob, then on your tRouteInput for that job, simply retrieve that header (as an Object) and cast it (maybe using a tJavaRow) to the type you want. 
Rilhia Solutions
Six Stars

Re: put a java variable inside the global map

thanks now it works