YMA
YMA

Reputation: 259

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!

Upvotes: 4

Views: 10415

Answers (3)

Mohammad Hasan
Mohammad Hasan

Reputation: 143

In camel xml dsl you can do this way.

<setBody>
    <!--fileName with location to be uploaded -->
    <constant>/data/myfiles/file.xml</constant>
</setBody>
<convertBodyTo type="java.io.File"/>

Upvotes: 1

quadrix
quadrix

Reputation: 66

In DSL style like this:

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

Upvotes: 1

Claus Ibsen
Claus Ibsen

Reputation: 55535

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.

Upvotes: 13

Related Questions