This Confluence has been LDAP enabled, if you are an ASF Committer, please use your LDAP Credentials to login. Any problems file an INFRA jira ticket please.

Child pages
  • Language
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »


Available as of Camel 2.5

The language component allows you to send Exchange to an endpoint which executes a script by any of the supported Languages in Camel.
By having a component to execute language scripts, it allows more dynamic routing capabilities. For example by using the Routing Slip or Dynamic Router EIPs you can send messages to language endpoints where the script is dynamic defined as well.

This component is provided out of the box in camel-core and hence no additional JARs is needed. You only have to include additional Camel components if the language of choice mandates it, such as using Groovy or JavaScript languages.

URI format


URI Options

The component supports the following options.

Unknown macro: {div}


Default Value






The name of the Language to use, such as simple, groovy, javascript etc. This option is mandatory.




The script to execute.




Whether or not the result of the script should be used as the new message body. By setting to false the script is executed but the result of the script is discarded.

Message Headers

The following message headers can be used to affect the behavior of the component

Unknown macro: {div}




The script to execute provided in the header. Takes precedence over script configured on the endpoint.


For example you can use the Simple language to Message Translator a message:

Error formatting macro: snippet: java.lang.IndexOutOfBoundsException: Index: 20, Size: 20

In case you want to convert the message body type you can do this as well:

Error formatting macro: snippet: java.lang.IndexOutOfBoundsException: Index: 20, Size: 20

You can also use the Groovy language, such as this example where the input message will by multiplied with 2:

Error rendering macro 'code': Invalid value specified for parameter 'java.lang.NullPointerException'
String script = URLEncoder.encode("request.body * 2", "UTF-8");
from("direct:start").to("language:groovy:" + script).to("mock:result");

You can also provide the script as a header as shown below. Here we use XPath language to extract the text from the <foo> tag.

Object out = producer.requestBodyAndHeader("language:xpath", "<foo>Hello World</foo>", Exchange.LANGUAGE_SCRIPT, "/foo/text()");
assertEquals("Hello World", out);

See Also

  • No labels