SQL

Overview

The SQL support is added by JoSQL(http://josql.sourceforge.net/) and is primarily used for performing SQL queries on in-memory objects. The SQL support is part of the camel-josql module.

Adding the JoSQL module

To use Ruby in your routes you need to add a dependency on camel-josql to your project as shown in Example 19, “Adding the camel-script dependency”.

Example 19. Adding the camel-script dependency

<!-- Maven POM File -->
...
<dependencies>
  ...
  <dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-josql</artifactId>
    <version>${camel-version}</version>
  </dependency>
  ...
</dependencies>

Variables

Table 12, “SQL variables” lists the variables that are accessible when using SQL.

Table 12. SQL variables

NameTypeDescription
exchangeorg.apache.camel.ExchangeThe current Exchange
inorg.apache.camel.MessageThe IN message
outorg.apache.camel.MessageThe OUT message
propertyObjectthe Exchange property whose key is property
headerObjectthe IN message header whose key is header
variableObjectthe variable whose key is variable

Example

Example 20, “Route using SQL” shows a route that uses SQL.

Example 20. Route using SQL

<camelContext>
  <route>
    <from uri="direct:start"/>
    <setBody>
      <langauge langauge="sql">select * from MyType</langauge>
    </setBody>
    <to uri="seda:regularQueue"/>
  </route>
</camelContext>