...
If you use maven you could just add the following to your pom.xml, substituting the version number for the latest & greatest release (see the download page for the latest versions).
Code Block | ||||
---|---|---|---|---|
| ||||
<dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-josql</artifactId> <version>2<version>x.5x.0<x</version> <!-- use the same version as your Camel core version --> </dependency> |
Camel supports SQL to allow an Expression or Predicate to be used in the DSL or Xml Configuration. For example you could use SQL to create an Predicate in a Message Filter or as an Expression for a Recipient List.
Code Block |
---|
from("queue:foo").setBody().sql("select * from MyType").to("queue:bar")
|
And the spring DSL:
Code Block | ||||
---|---|---|---|---|
| ||||
<from uri="queue:foo"/>
<setBody>
<sql>select * from MyType</sql>
</setBody>
<to uri="queue:bar"/>
|
...
Variable | Type | Description |
---|---|---|
exchange | Exchange | the Exchange object |
in | Message | the exchange.in message |
out | Message | the exchange.out message |
the property key | Object | the Exchange properties |
the header key | Object | the exchange.in headers |
the variable key | Object | if any additional variables is added using |
Loading script from external resource
Available as of Camel 2.11
You can externalize the script and have Camel load it from a resource such as "classpath:"
, "file:"
, or "http:"
.
This is done using the following syntax: "resource:scheme:location"
, eg to refer to a file on the classpath you can do:
Code Block |
---|
.setHeader("myHeader").sql("resource:classpath:mysql.sql")
|