blob: fd7cdc008de2ad241ddd3f9d4e8394c857509136 [file] [log] [blame]
= JOOQ Example
== Introduction
This example shows how to use JOOQ library with Camel to build type safe SQL queries through its API.
Example project contains SQL script to create database.
Database is generated every time when Maven `generate-sources` phase is triggered.
JOOQ classes are generated inside `target/generated-sources/jooq` directory by `jooq-codegen-maven` plugin.
== Build
You will need to compile this example first:
mvn clean install
This command will generate database and JOOQ classes.
== Run with maven
To run the example using Maven type
mvn camel:run
To stop the example hit kbd:[Ctrl+c]
== Example routes
<camelContext xmlns="">
<!-- Producer -->
<route id="produce-route">
<from uri="timer://insert?fixedRate=true&amp;period=1000"/>
<!-- Insert -->
<method ref="book-store" method="generate"/>
<to uri="jooq://org.apache.camel.examples.jooq.db.tables.records.BookStoreRecord"/>
<log message="Inserted: ${body}"/>
<!-- Select -->
<method ref="book-store" method="select"/>
<to uri="jooq://org.apache.camel.examples.jooq.db.tables.records.BookStoreRecord/fetch"/>
<log message="Selected: ${body}"/>
<!-- Consumer -->
<route id="consume-route">
<from uri="jooq://org.apache.camel.examples.jooq.db.tables.records.BookStoreRecord?consumer.delay=5000&amp;consumeDelete=true"/>
<log message="Consumed: ${body}"/>
In this example route `produce-route` inserts and selects new entity every 1s.
And the consumer route `consume-route` selects and deletes all entities from database every 5s.
== Forum, Help, etc
If you hit an problems please let us know on the Camel Forums
Please help us make Apache Camel better - we appreciate any feedback you may
have. Enjoy!
The Camel riders!