Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[Talend 6.2.0] doTry on setHeader does not work

Hi,
I am using Talend Open Studio for ESB v6.2.0 and Karaf 4.0.5.
Camel route (.kar) is as follows and is deployed in container/deploy
talend-camel floow ---> cDoTry --> cJavaDSLComponent (setHeader("X-Field").simple("${header.X-AnotherField}"))
                                   cCatch (Exception.class)  --> cJavaDSLComponent (setHeader("X-Field").contant("some value"))
                                   cFinally --> flow continues
If the header.X-AnotherField exists, everything works fine. If the header does not exist, flow fails silently (no error or exception thrown) at doTry and does not continue.
Similar behaviour happens with fetching values to header via jsonpath. Replacing cJavaDSLComponent for cSetHeader component is same.
Is this intended behaviour, am I using the components wrong?

Labels (2)
2 Replies
Anonymous
Not applicable
Author

Martin, just use a "CProcessor" component with the following few lines: ( copy and paste these lines in the CProcessor "basic settings"->"Code" area )
String vXAnotherField = (String)exchange.getIn().getHeader("X-AnotherField");
if(vXAnotherField == null) 
exchange.getIn().setHeader("X-Field","some value"); 
else
exchange.getIn().setHeader("X-Field",vXAnotherField); 
as shown bellow:
0683p000009MBG3.png
you don't need to crate any try/catch block.
Hope this helps, Esteban. 
Anonymous
Not applicable
Author

Thank you zarcap, cProcessor works fine. I guess usage of cPRocessor is much more effective than using talend components as cSetHeader.