Using context variable in a mediation route (ESB 6.3)

One Star

Using context variable in a mediation route (ESB 6.3)

Hello,

I have a weird problem while using context variables in mediation routes with Talend ESB 6.3.1

 

I have no idea how to join the .zip of my route in here, but you can reproduce very easily :

 

cTimer -> cDirect (setVar) -> cLog (output message : context.var)

cDirect (setVar) -> cProcessor (context.var = "Fixed") -> cLog (output message : context.var) 

image.png

 

My route is a bit more complex because I also tried to System.out.println the context variable, and use it in the "When" link of a message Router. Result is shown below :

 

image.png

 

Here it is, in the cProcessor called "setting context var", I print it, the fix it to "fixed", then print it again : it works.

Then, the cLog2 prints it, but it shows the default value, not "fixed". Why ?

Same for the cLog1 in the first route, it shows "default", however the cProcessor shows the value "fixed" right after cLog1!

Without any surprise, this context variable in the message router has the "default" value instead of "fixed".

 

Why does it behave like this ? Is there something I missed somewhere ?

 

Thanks in advance

 

 

Ten Stars

Re: Using context variable in a mediation route (ESB 6.3)

I'm not very familiar with Talend ESB, but with no connection between the subjobs, I'm guessing they run simultaneously. If that's true, the execution order will be unpredictable.
Twelve Stars

Re: Using context variable in a mediation route (ESB 6.3)

as @cterenzi suggest - need to check how the routes executed, You can run it in debug mode 

 

generally - it work, for example - below part of job, which catch exceptions from real-time flow, but send email not more often than 1 per 30 minutes

 

Screen Shot 2017-06-09 at 2.42.30 PM.png

 

Other part of this Job use variables as well, but I never mix them between parts

-----------
Six Stars

Re: Using context variable in a mediation route (ESB 6.3)

Has anyone got solution for this? 

Sixteen Stars

Re: Using context variable in a mediation route (ESB 6.3)

I'm not quite sure what you're trying to achieve, but I'm picking up on the fact that you are thinking about routes in the wrong way. Context variables in Data Integration can be manipulated easily. You only need to account for timing of rows and the knowledge that 1 row will follow another. Routes are slightly different in that you are dealing with the lifespan of a message. You cannot guarantee the transit or order of the messages, so you need to tie variables to the message. Context variables in routes are really not that useful unless you are using them to define endpoints in different environments. What you need to use here are headers. You can set headers on your messages using the csetheader component (https://help.talend.com/reader/_kirWdGiwNgvHlXUtw8vGA/PJMBt6~g0wBzv97ZUwEpUw).