'Apache Camel: Set body from resource

Basically, I'm trying to do this (incorrect code!):

  <camel:setBody>
    <camel:simple>resource:classpath:/myfiles/file.xml</camel:simple>
  </camel:setBody>

How would you do this properly?

Cheers!



Solution 1:[1]

You can possible try with

<to uri="language:constant:resource:classpath:/myfiles/file.xml"/>

To use the language component: http://camel.apache.org/language.html To load the content.

Solution 2:[2]

In DSL style like this:

.setBody(constant("resource:classpath:foo/bar/baz/some.sql"))

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Claus Ibsen
Solution 2 quadrix