SQL has been edited by Claus Ibsen (Sep 20, 2008).

Change summary:

CAMEL-907

(View changes)

Content:

SQL

The SQL support is added by JoSQL and is primarily used for performing SQL queries on in-memory objects. If you prefer to perform actual database queries then check out the JPA component.

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.

To add an SQL _expression_ to your routing rules its usually easiest to import the SqlBuilder classes methods then you can use the sql() function inside your rules.

import static org.apache.camel.builder.sql.SqlBuilder.*;
...
from("queue:foo").setBody(sql("select * from MyType")).to("queue:bar")

Syntax

_expression_ 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 setVariables method

Dependencies

To use SQL in your camel routes you need to add the a dependency on camel-josql which implements the SQL language.

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).

<dependency>
  <groupId>org.apache.camel</groupId>
  <artifactId>camel-josql</artifactId>
  <version>1.4.0</version>
</dependency>

Reply via email to