Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejava
from("jms:order.inbox")
	.to("sql:select order_seq.nextval from dual?outputHeader=OrderId&outputType=SelectOne")
	.to("jms:order.booking");

Using StreamList

From Camel 2.18 onwards the producer supports outputType=StreamList that uses an iterator to stream the output of the query. This allows to process the data in a streaming fashion which for example can be used by the Splitter EIP to process each row one at a time, and load data from the database as needed.

Code Block
java
java
from("direct:withSplitModel")
        .to("sql:select * from projects order by id?outputType=StreamList&outputClass=org.apache.camel.component.sql.ProjectModel")
        .to("log:stream")
        .split(body()).streaming()
            .to("log:row")
            .to("mock:result")
        .end();

 

Header values

When performing update operations, the SQL Component stores the update count in the following message headers:

Header

Description

CamelSqlUpdateCount

The number of rows updated for update operations, returned as an Integer object. This header is not provided when using outputType=StreamList.

CamelSqlRowCount

The number of rows returned for select operations, returned as an Integer object. This header is not provided when using outputType=StreamList.

CamelSqlQuery

Camel 2.8: Query to execute. This query takes precedence over the query specified in the endpoint URI. Note that query parameters in the header are represented by a ? instead of a # symbol

...