Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

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

Wiki Markup
{snippet:id=e1|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/component/language/LanguageRouteTest.java}
In case you want to convert the message body type you can do this as well:
Wiki Markup
{snippet:id=e1|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/component/language/LanguageRouteConvertBodyTest.java}
You can also use the Groovy language, such as this example where the input message will by multiplied with 2:
Wiki Markup
{snippet:id=e1|lang=java|url=camel/trunk/components/camel-groovy/src/test/java/org/apache/camel/language/groovy/LanguageGroovyRouteTest.java}
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.

...

For example to load a script from the classpath:

Wiki Markup
{snippet:id=e1|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/component/language/LanguageLoadScriptFromClasspathTest.java}
By default the script is loaded once and cached. However you can disable the contentCache option and have the script loaded on each evaluation.
For example if the file myscript.txt is changed on disk, then the updated script is used:
Wiki Markup
{snippet:id=e1|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/component/language/LanguageLoadScriptFromFileUpdateTest.java}
From Camel 2.11 onwards you can refer to the resource similar to the other Languages in Camel by prefixing with "resource:" as shown below:
Wiki Markup
{snippet:id=e1|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/component/language/LanguageResourceLoadScriptFromClasspathTest.java}
Include Page
Endpoint See Also
Endpoint See Also