Quantcast
Viewing all articles
Browse latest Browse all 5648

looking for a way to run javascript in camel and set message headers

Hello camel community,

I'm trying to figure it a way to run a real javascript procedures in camel as an alternative to use java code out of a bean.

My company is using camel routes from a spring dsl xml file and we would like to minimize our java coding effort. I know that javascript can be used in expressions, filters, ... but I can't figure out to more with it like:
<route>
<javaScript>
var content = request.getBody().toString().toUpperCase();
if (match("^UN[AB][+]{1}.*") != null) {
request.headers.set("datatype", "edifact");
} else {
request.headers.set("datatype", "xml");

</javaScript>
</route>

Please don't comment on the content of the javascript because this is just a very simple example. Things that I surely want to do is setting message (and attachment) headers.

The fact that javascript can be loading from an external file (since camel 2.11) is already of much help.

Intris nv
Wapenstilstandlaan 47
B-2600 Berchem
Tel. +32 3 326 50 75
Fax +32 3 326 42 23
www.intris.be<http://www.intris.be/>

DISCLAIMER
This is an e-mail from Intris. The information contained in this communication is intended solely for use by the individual or entity to whom it is addressed.
Use of this communication by others is prohibited. If the e-mail message was sent to you by mistake, please notify support [ at ] intris.be<mailto:support [ at ] intris.be, destroy it without reading, using, copying or disclosing its contents to any other person.
We accept no liability for damage related to data and/or documents which are communicated by electronic mail.

Viewing all articles
Browse latest Browse all 5648

Trending Articles