Author: buildbot
Date: Tue Jan 21 15:19:52 2014
New Revision: 894976
Log:
Production update by buildbot for camel
Modified:
websites/production/camel/content/cache/main.pageCache
websites/production/camel/content/mybatis.html
Modified: websites/production/camel/content/cache/main.pageCache
==============================================================================
Binary files - no diff available.
Modified: websites/production/camel/content/mybatis.html
==============================================================================
--- websites/production/camel/content/mybatis.html (original)
+++ websites/production/camel/content/mybatis.html Tue Jan 21 15:19:52 2014
@@ -86,69 +86,27 @@
<tbody>
<tr>
<td valign="top" width="100%">
-<div class="wiki-content maincontent"><h2 id="MyBatis-MyBatis">MyBatis</h2>
-<p><strong>Available as of Camel 2.7</strong></p>
-
-<p>The <strong>mybatis:</strong> component allows you to query, poll, insert,
update and delete data in a relational database using <a shape="rect"
class="external-link" href="http://mybatis.org/" rel="nofollow">MyBatis</a>.</p>
-
-<p>Maven users will need to add the following dependency to their
<code>pom.xml</code> for this component:</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="theme: Default; brush: xml; gutter: false"
type="syntaxhighlighter"><![CDATA[
-<dependency>
+<div class="wiki-content maincontent"><h2
id="MyBatis-MyBatis">MyBatis</h2><p><strong>Available as of Camel
2.7</strong></p><p>The <strong>mybatis:</strong> component allows you to query,
poll, insert, update and delete data in a relational database using <a
shape="rect" class="external-link" href="http://mybatis.org/"
rel="nofollow">MyBatis</a>.</p><p>Maven users will need to add the following
dependency to their <code>pom.xml</code> for this component:</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+<script class="theme: Default; brush: xml; gutter: false"
type="syntaxhighlighter"><![CDATA[<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-mybatis</artifactId>
<version>x.x.x</version>
<!-- use the same version as your Camel core version -->
</dependency>
]]></script>
-</div></div>
-
-<h3 id="MyBatis-URIformat">URI format</h3>
-
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
-mybatis:statementName[?options]
+</div></div><h3 id="MyBatis-URIformat">URI format</h3><div class="code panel
pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[mybatis:statementName[?options]
]]></script>
-</div></div>
-
-<p>Where <strong>statementName</strong> is the statement name in the MyBatis
XML mapping file which maps to the query, insert, update or delete operation
you wish to evaluate.</p>
-
-<p>You can append query options to the URI in the following format,
<code>?option=value&option=value&...</code></p>
-
-<p>This component will by default load the MyBatis SqlMapConfig file from the
root of the classpath with the expected name of
<code>SqlMapConfig.xml</code>.<br clear="none">
-If the file is located in another location, you will need to configure the
<code>configurationUri</code> option on the <code>MyBatisComponent</code>
component.</p>
-
-<h3 id="MyBatis-Options">Options</h3>
-<div class="confluenceTableSmall">
+</div></div><p>Where <strong>statementName</strong> is the statement name in
the MyBatis XML mapping file which maps to the query, insert, update or delete
operation you wish to evaluate.</p><p>You can append query options to the URI
in the following format,
<code>?option=value&option=value&...</code></p><p>This component will
by default load the MyBatis SqlMapConfig file from the root of the classpath
with the expected name of <code>SqlMapConfig.xml</code>.<br clear="none"> If
the file is located in another location, you will need to configure the
<code>configurationUri</code> option on the <code>MyBatisComponent</code>
component.</p><h3 id="MyBatis-Options">Options</h3><div
class="confluenceTableSmall">
<table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1"
class="confluenceTh"><p> Option </p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p> Type </p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p> Default </p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p> Description </p></th></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p> <code>consumer.onConsume</code>
</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>
<code>String</code> </p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p> <code>null</code> </p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p> Statements to run after consuming. Can be used, for
example, to update rows after they have been consumed and processed in Camel.
See sample later. Multiple statements can be separated with commas.
</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>
<code>consumer.useIterator</code> </p></td><td colspan="1" rowspan="1"
class="confluence
Td"><p> <code>boolean</code> </p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p> <code>true</code> </p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p> If <code>true</code> each row returned when polling
will be processed individually. If <code>false</code> the entire
<code>List</code> of data is set as the IN body. </p></td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"><p>
<code>consumer.routeEmptyResultSet</code> </p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p> <code>boolean</code> </p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p> <code>false</code> </p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p> Sets whether empty result sets
should be routed. </p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p> <code>statementType</code> </p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p> <code>StatementType</code> </p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p> <code>null</code> </p><
/td><td colspan="1" rowspan="1" class="confluenceTd"><p> Mandatory to specify
for the producer to control which kind of operation to invoke. The enum values
are: <code>SelectOne</code>, <code>SelectList</code>, <code>Insert</code>,
<code>InsertList</code>, <code>Update</code>, <code>UpdateList</code>,
<code>Delete</code>, and <code>DeleteList</code>. <strong>Notice:</strong>
<code>InsertList</code> is available as of Camel 2.10, and
<code>UpdateList</code>, <code>DeleteList</code> is available as of Camel 2.11.
</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>
<code>maxMessagesPerPoll</code> </p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p> <code>int</code> </p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p> <code>0</code> </p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p> An integer to define the maximum messages to gather
per poll. By default, no maximum is set. Can be used to set a limit of e.g.
1000 to avoid when starting up
the server that there are thousands of files. Set a value of 0 or negative to
disable it. </p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p> <code>executorType</code> </p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p> <code>String</code> </p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p> <code>null</code> </p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p> <strong>Camel 2.11:</strong>
The executor type to be used while executing statements. The supported values
are: simple, reuse, batch. By default, the value is not specified and is equal
to what MyBatis uses, i.e. <strong>simple</strong>. <br clear="none"
class="atl-forced-newline"> <strong>simple</strong> executor does nothing
special. <br clear="none" class="atl-forced-newline"> <strong>reuse</strong>
executor reuses prepared statements. <br clear="none"
class="atl-forced-newline"> <strong>batch</strong> executor reuses statements
and batches updates. </p></td></tr></tbody></tab
le>
-</div>
-
-<h3 id="MyBatis-MessageHeaders">Message Headers</h3>
-<p>Camel will populate the result message, either IN or OUT with a header with
the statement used:</p>
-<div class="confluenceTableSmall">
+</div><h3 id="MyBatis-MessageHeaders">Message Headers</h3><p>Camel will
populate the result message, either IN or OUT with a header with the statement
used:</p><div class="confluenceTableSmall">
<table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1"
class="confluenceTh"><p> Header </p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p> Type </p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p> Description </p></th></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p> <code>CamelMyBatisStatementName</code>
</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>
<code>String</code> </p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p> The <strong>statementName</strong> used (for example:
insertAccount). </p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p> <code>CamelMyBatisResult</code> </p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p> <code>Object</code>
</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> The
<strong>response</strong> returned from MtBatis in any of the operations. For
instance an <code>INSERT</code> could return the auto-generated key, or number
of rows etc. </p></td>
</tr></tbody></table>
-</div>
-
-<h3 id="MyBatis-MessageBody">Message Body</h3>
-<p>The response from MyBatis will only be set as the body if it's a
<code>SELECT</code> statement. That means, for example, for <code>INSERT</code>
statements Camel will not replace the body. This allows you to continue routing
and keep the original body. The response from MyBatis is always stored in the
header with the key <code>CamelMyBatisResult</code>.</p>
-
-<h3 id="MyBatis-Samples">Samples</h3>
-
-<p>For example if you wish to consume beans from a JMS queue and insert them
into a database you could do the following:</p>
-
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
-from("activemq:queue:newAccount").
+</div><h3 id="MyBatis-MessageBody">Message Body</h3><p>The response from
MyBatis will only be set as the body if it's a <code>SELECT</code> statement.
That means, for example, for <code>INSERT</code> statements Camel will not
replace the body. This allows you to continue routing and keep the original
body. The response from MyBatis is always stored in the header with the key
<code>CamelMyBatisResult</code>.</p><h3 id="MyBatis-Samples">Samples</h3><p>For
example if you wish to consume beans from a JMS queue and insert them into a
database you could do the following:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[from("activemq:queue:newAccount").
to("mybatis:insertAccount?statementType=Insert");
]]></script>
-</div></div>
-
-<p>Notice we have to specify the <code>statementType</code>, as we need to
instruct Camel which kind of operation to invoke.</p>
-
-<p>Where <strong>insertAccount</strong> is the MyBatis ID in the SQL mapping
file:</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="theme: Default; brush: xml; gutter: false"
type="syntaxhighlighter"><![CDATA[
- <!-- Insert example, using the Account parameter class -->
+</div></div><p>Notice we have to specify the <code>statementType</code>, as we
need to instruct Camel which kind of operation to invoke.</p><p>Where
<strong>insertAccount</strong> is the MyBatis ID in the SQL mapping
file:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
+<script class="theme: Default; brush: xml; gutter: false"
type="syntaxhighlighter"><![CDATA[ <!-- Insert example, using the Account
parameter class -->
<insert id="insertAccount" parameterType="Account">
insert into ACCOUNT (
ACC_ID,
@@ -161,43 +119,25 @@ from("activemq:queue:newAccount&quo
)
</insert>
]]></script>
-</div></div>
-
-<h3 id="MyBatis-UsingStatementTypeforbettercontrolofMyBatis">Using
StatementType for better control of MyBatis</h3>
-<p>When routing to an MyBatis endpoint you will want more fine grained control
so you can control whether the SQL statement to be executed is a
<code>SELECT</code>, <code>UPDATE</code>, <code>DELETE</code> or
<code>INSERT</code> etc. So for instance if we want to route to an MyBatis
endpoint in which the IN body contains parameters to a <code>SELECT</code>
statement we can do:</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+</div></div><h3 id="MyBatis-UsingStatementTypeforbettercontrolofMyBatis">Using
StatementType for better control of MyBatis</h3><p>When routing to an MyBatis
endpoint you will want more fine grained control so you can control whether the
SQL statement to be executed is a <code>SELECT</code>, <code>UPDATE</code>,
<code>DELETE</code> or <code>INSERT</code> etc. So for instance if we want to
route to an MyBatis endpoint in which the IN body contains parameters to a
<code>SELECT</code> statement we can do:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
from("direct:start")
.to("mybatis:selectAccountById?statementType=SelectOne")
.to("mock:result");
]]></script>
-</div></div>
-
-<p>In the code above we can invoke the MyBatis statement
<code>selectAccountById</code> and the IN body should contain the account id we
want to retrieve, such as an <code>Integer</code> type.</p>
-
-<p>We can do the same for some of the other operations, such as
<code>SelectList</code>:</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+</div></div><p>In the code above we can invoke the MyBatis statement
<code>selectAccountById</code> and the IN body should contain the account id we
want to retrieve, such as an <code>Integer</code> type.</p><p>We can do the
same for some of the other operations, such as <code>SelectList</code>:</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
from("direct:start")
.to("mybatis:selectAllAccounts?statementType=SelectList")
.to("mock:result");
]]></script>
-</div></div>
-
-<p>And the same for <code>UPDATE</code>, where we can send an
<code>Account</code> object as the IN body to MyBatis:</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+</div></div><p>And the same for <code>UPDATE</code>, where we can send an
<code>Account</code> object as the IN body to MyBatis:</p><div class="code
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
from("direct:start")
.to("mybatis:updateAccount?statementType=Update")
.to("mock:result");
]]></script>
-</div></div>
-
-<h4 id="MyBatis-UsingInsertListStatementType">Using InsertList
StatementType</h4>
-<p><strong>Available as of Camel 2.10</strong></p>
-
-<p>MyBatis allows you to insert multiple rows using its for-each batch driver.
To use this, you need to use the <foreach> in the mapper XML file. For
example as shown below:</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+</div></div><h4 id="MyBatis-UsingInsertListStatementType">Using InsertList
StatementType</h4><p><strong>Available as of Camel 2.10</strong></p><p>MyBatis
allows you to insert multiple rows using its for-each batch driver. To use
this, you need to use the <foreach> in the mapper XML file. For example
as shown below:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
<script class="theme: Default; brush: xml; gutter: false"
type="syntaxhighlighter"><![CDATA[
<!-- Batch Insert example, using the Account parameter class -->
<insert id="batchInsertAccount"
parameterType="java.util.List">
@@ -214,25 +154,14 @@ from("direct:start")
)
</insert>
]]></script>
-</div></div>
-
-<p>Then you can insert multiple rows, by sending a Camel message to the
<code>mybatis</code> endpoint which uses the <code>InsertList</code> statement
type, as shown below:</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+</div></div><p>Then you can insert multiple rows, by sending a Camel message
to the <code>mybatis</code> endpoint which uses the <code>InsertList</code>
statement type, as shown below:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
from("direct:start")
.to("mybatis:batchInsertAccount?statementType=InsertList")
.to("mock:result");
]]></script>
-</div></div>
-
-
-<h4 id="MyBatis-UsingUpdateListStatementType">Using UpdateList
StatementType</h4>
-<p><strong>Available as of Camel 2.11</strong></p>
-
-<p>MyBatis allows you to update multiple rows using its for-each batch driver.
To use this, you need to use the <foreach> in the mapper XML file. For
example as shown below:</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="theme: Default; brush: xml; gutter: false"
type="syntaxhighlighter"><![CDATA[
-<update id="batchUpdateAccount"
parameterType="java.util.Map">
+</div></div><h4 id="MyBatis-UsingUpdateListStatementType">Using UpdateList
StatementType</h4><p><strong>Available as of Camel 2.11</strong></p><p>MyBatis
allows you to update multiple rows using its for-each batch driver. To use
this, you need to use the <foreach> in the mapper XML file. For example
as shown below:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
+<script class="theme: Default; brush: xml; gutter: false"
type="syntaxhighlighter"><![CDATA[<update id="batchUpdateAccount"
parameterType="java.util.Map">
update ACCOUNT set
ACC_EMAIL = #{emailAddress}
where
@@ -242,25 +171,13 @@ from("direct:start")
</foreach>
</update>
]]></script>
-</div></div>
-
-<p>Then you can update multiple rows, by sending a Camel message to the
mybatis endpoint which uses the UpdateList statement type, as shown below:</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
-from("direct:start")
+</div></div><p>Then you can update multiple rows, by sending a Camel message
to the mybatis endpoint which uses the UpdateList statement type, as shown
below:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
+<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[from("direct:start")
.to("mybatis:batchUpdateAccount?statementType=UpdateList")
.to("mock:result");
]]></script>
-</div></div>
-
-
-<h4 id="MyBatis-UsingDeleteListStatementType">Using DeleteList
StatementType</h4>
-<p><strong>Available as of Camel 2.11</strong></p>
-
-<p>MyBatis allows you to delete multiple rows using its for-each batch driver.
To use this, you need to use the <foreach> in the mapper XML file. For
example as shown below:</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="theme: Default; brush: xml; gutter: false"
type="syntaxhighlighter"><![CDATA[
-<delete id="batchDeleteAccountById"
parameterType="java.util.List">
+</div></div><h4 id="MyBatis-UsingDeleteListStatementType">Using DeleteList
StatementType</h4><p><strong>Available as of Camel 2.11</strong></p><p>MyBatis
allows you to delete multiple rows using its for-each batch driver. To use
this, you need to use the <foreach> in the mapper XML file. For example
as shown below:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
+<script class="theme: Default; brush: xml; gutter: false"
type="syntaxhighlighter"><![CDATA[<delete
id="batchDeleteAccountById"
parameterType="java.util.List">
delete from ACCOUNT
where
ACC_ID in
@@ -269,77 +186,40 @@ from("direct:start")
</foreach>
</delete>
]]></script>
-</div></div>
-
-<p>Then you can delete multiple rows, by sending a Camel message to the
mybatis endpoint which uses the DeleteList statement type, as shown below:</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
-from("direct:start")
+</div></div><p>Then you can delete multiple rows, by sending a Camel message
to the mybatis endpoint which uses the DeleteList statement type, as shown
below:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
+<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[from("direct:start")
.to("mybatis:batchDeleteAccount?statementType=DeleteList")
.to("mock:result");
]]></script>
-</div></div>
-
-<h4
id="MyBatis-NoticeonInsertList,UpdateListandDeleteListStatementTypes">Notice on
InsertList, UpdateList and DeleteList StatementTypes</h4>
-<p>Parameter of any type (List, Map, etc.) can be passed to mybatis and an end
user is responsible for handling it as required<br clear="none">
-with the help of <a shape="rect" class="external-link"
href="http://www.mybatis.org/core/dynamic-sql.html" rel="nofollow">mybatis
dynamic queries</a> capabilities.</p>
-
-
-<h4 id="MyBatis-Scheduledpollingexample">Scheduled polling example</h4>
-<p>Since this component does not support scheduled polling, you need to use
another mechanism for triggering the scheduled polls, such as the <a
shape="rect" href="timer.html">Timer</a> or <a shape="rect"
href="quartz.html">Quartz</a> components.</p>
-
-<p>In the sample below we poll the database, every 30 seconds using the <a
shape="rect" href="timer.html">Timer</a> component and send the data to the JMS
queue:</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
-from("timer://pollTheDatabase?delay=30000").to("mbatis:selectAllAccounts").to("activemq:queue:allAccounts");
+</div></div><h4
id="MyBatis-NoticeonInsertList,UpdateListandDeleteListStatementTypes">Notice on
InsertList, UpdateList and DeleteList StatementTypes</h4><p>Parameter of any
type (List, Map, etc.) can be passed to mybatis and an end user is responsible
for handling it as required<br clear="none"> with the help of <a shape="rect"
class="external-link" href="http://www.mybatis.org/core/dynamic-sql.html"
rel="nofollow">mybatis dynamic queries</a> capabilities.</p><h4
id="MyBatis-Scheduledpollingexample">Scheduled polling example</h4><p>This
component supports scheduled polling and can therefore be used as a <a
shape="rect" href="polling-consumer.html">Polling Consumer</a>. For example to
poll the database every minute:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[from("mybatis:selectAllAccounts?delay=60000").to("activemq:queue:allAccounts");]]></script>
+</div></div><p>See "ScheduledPollConsumer Options" on <a shape="rect"
href="polling-consumer.html">Polling Consumer</a> for more
options.</p><p>Alternatively you can use another mechanism for triggering the
scheduled polls, such as the <a shape="rect" href="timer.html">Timer</a> or <a
shape="rect" href="quartz.html">Quartz</a> components. <span
style="line-height: 1.4285715;">In the sample below we poll the database, every
30 seconds using the </span><a shape="rect" href="timer.html">Timer</a><span
style="line-height: 1.4285715;"> component and send the data to the JMS
queue:</span></p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
+<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[from("timer://pollTheDatabase?delay=30000").to("mybatis:selectAllAccounts").to("activemq:queue:allAccounts");
]]></script>
-</div></div>
-
-<p>And the MyBatis SQL mapping file used:</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="theme: Default; brush: xml; gutter: false"
type="syntaxhighlighter"><![CDATA[
- <!-- Select with no parameters using the result map for Account class.
-->
+</div></div><p>And the MyBatis SQL mapping file used:</p><div class="code
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<script class="theme: Default; brush: xml; gutter: false"
type="syntaxhighlighter"><![CDATA[ <!-- Select with no parameters using the
result map for Account class. -->
<select id="selectAllAccounts"
resultMap="AccountResult">
select * from ACCOUNT
</select>
]]></script>
-</div></div>
-
-<h4 id="MyBatis-UsingonConsume">Using onConsume</h4>
-<p>This component supports executing statements <strong>after</strong> data
have been consumed and processed by Camel. This allows you to do post updates
in the database. Notice all statements must be <code>UPDATE</code> statements.
Camel supports executing multiple statements whose names should be separated by
commas.</p>
-
-<p>The route below illustrates we execute the <strong>consumeAccount</strong>
statement data is processed. This allows us to change the status of the row in
the database to processed, so we avoid consuming it twice or more.</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+</div></div><h4 id="MyBatis-UsingonConsume">Using onConsume</h4><p>This
component supports executing statements <strong>after</strong> data have been
consumed and processed by Camel. This allows you to do post updates in the
database. Notice all statements must be <code>UPDATE</code> statements. Camel
supports executing multiple statements whose names should be separated by
commas.</p><p>The route below illustrates we execute the
<strong>consumeAccount</strong> statement data is processed. This allows us to
change the status of the row in the database to processed, so we avoid
consuming it twice or more.</p><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
from("mybatis:selectUnprocessedAccounts?consumer.onConsume=consumeAccount").to("mock:results");
]]></script>
-</div></div>
-
-<p>And the statements in the sqlmap file:</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+</div></div><p>And the statements in the sqlmap file:</p><div class="code
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<script class="theme: Default; brush: xml; gutter: false"
type="syntaxhighlighter"><![CDATA[
<select id="selectUnprocessedAccounts"
resultMap="AccountResult">
select * from ACCOUNT where PROCESSED = false
</select>
]]></script>
-</div></div>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+</div></div><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
<script class="theme: Default; brush: xml; gutter: false"
type="syntaxhighlighter"><![CDATA[
<update id="consumeAccount" parameterType="Account">
update ACCOUNT set PROCESSED = true where ACC_ID = #{id}
</update>
]]></script>
-</div></div>
-
-<h4 id="MyBatis-Participatingintransactions">Participating in transactions</h4>
-
-<p>Setting up a transaction manager under camel-mybatis can be a little bit
fiddly, as it involves externalising the database configuration outside the
standard MyBatis <code>SqlMapConfig.xml</code> file.</p>
-
-<p>The first part requires the setup of a <code>DataSource</code>. This is
typically a pool (either DBCP, or c3p0), which needs to be wrapped in a Spring
proxy. This proxy enables non-Spring use of the <code>DataSource</code> to
participate in Spring transactions (the MyBatis <code>SqlSessionFactory</code>
does just this).</p>
-
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="theme: Default; brush: xml; gutter: false"
type="syntaxhighlighter"><![CDATA[
- <bean id="dataSource"
class="org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy">
+</div></div><h4 id="MyBatis-Participatingintransactions"><span
style="line-height: 1.5;">Participating in transactions</span></h4><p>Setting
up a transaction manager under camel-mybatis can be a little bit fiddly, as it
involves externalising the database configuration outside the standard MyBatis
<code>SqlMapConfig.xml</code> file.</p><p>The first part requires the setup of
a <code>DataSource</code>. This is typically a pool (either DBCP, or c3p0),
which needs to be wrapped in a Spring proxy. This proxy enables non-Spring use
of the <code>DataSource</code> to participate in Spring transactions (the
MyBatis <code>SqlSessionFactory</code> does just this).</p><div class="code
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<script class="theme: Default; brush: xml; gutter: false"
type="syntaxhighlighter"><![CDATA[ <bean id="dataSource"
class="org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy">
<constructor-arg>
<bean
class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass"
value="org.postgresql.Driver"/>
@@ -350,25 +230,13 @@ from("mybatis:selectUnprocessedAcco
</constructor-arg>
</bean>
]]></script>
-</div></div>
-
-<p>This has the additional benefit of enabling the database configuration to
be externalised using property placeholders.</p>
-
-<p>A transaction manager is then configured to manage the outermost
<code>DataSource</code>:</p>
-
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="theme: Default; brush: xml; gutter: false"
type="syntaxhighlighter"><![CDATA[
- <bean id="txManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
+</div></div><p>This has the additional benefit of enabling the database
configuration to be externalised using property placeholders.</p><p>A
transaction manager is then configured to manage the outermost
<code>DataSource</code>:</p><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
+<script class="theme: Default; brush: xml; gutter: false"
type="syntaxhighlighter"><![CDATA[ <bean id="txManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource"
ref="dataSource"/>
</bean>
]]></script>
-</div></div>
-
-<p>A <a shape="rect" class="external-link"
href="http://www.mybatis.org/spring/index.html"
rel="nofollow">mybatis-spring</a> <a shape="rect" class="external-link"
href="http://www.mybatis.org/spring/factorybean.html"
rel="nofollow"><code>SqlSessionFactoryBean</code></a> then wraps that same
<code>DataSource</code>:</p>
-
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="theme: Default; brush: xml; gutter: false"
type="syntaxhighlighter"><![CDATA[
- <bean id="sqlSessionFactory"
class="org.mybatis.spring.SqlSessionFactoryBean">
+</div></div><p>A <a shape="rect" class="external-link"
href="http://www.mybatis.org/spring/index.html"
rel="nofollow">mybatis-spring</a> <a shape="rect" class="external-link"
href="http://www.mybatis.org/spring/factorybean.html"
rel="nofollow"><code>SqlSessionFactoryBean</code></a> then wraps that same
<code>DataSource</code>:</p><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
+<script class="theme: Default; brush: xml; gutter: false"
type="syntaxhighlighter"><![CDATA[ <bean id="sqlSessionFactory"
class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource"
ref="dataSource"/>
<!-- standard mybatis config file -->
<property name="configLocation"
value="/META-INF/SqlMapConfig.xml"/>
@@ -376,23 +244,13 @@ from("mybatis:selectUnprocessedAcco
<property name="mapperLocations"
value="classpath*:META-INF/mappers/**/*.xml"/>
</bean>
]]></script>
-</div></div>
-
-<p>The camel-mybatis component is then configured with that factory:</p>
-
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="theme: Default; brush: xml; gutter: false"
type="syntaxhighlighter"><![CDATA[
- <bean id="mybatis"
class="org.apache.camel.component.mybatis.MyBatisComponent">
+</div></div><p>The camel-mybatis component is then configured with that
factory:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
+<script class="theme: Default; brush: xml; gutter: false"
type="syntaxhighlighter"><![CDATA[ <bean id="mybatis"
class="org.apache.camel.component.mybatis.MyBatisComponent">
<property name="sqlSessionFactory"
ref="sqlSessionFactory"/>
</bean>
]]></script>
-</div></div>
-
-<p>Finally, a <a shape="rect" href="transactional-client.html">transaction
policy</a> is defined over the top of the transaction manager, which can then
be used as usual:</p>
-
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="theme: Default; brush: xml; gutter: false"
type="syntaxhighlighter"><![CDATA[
- <bean id="PROPAGATION_REQUIRED"
class="org.apache.camel.spring.spi.SpringTransactionPolicy">
+</div></div><p>Finally, a <a shape="rect"
href="transactional-client.html">transaction policy</a> is defined over the top
of the transaction manager, which can then be used as usual:</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+<script class="theme: Default; brush: xml; gutter: false"
type="syntaxhighlighter"><![CDATA[ <bean
id="PROPAGATION_REQUIRED"
class="org.apache.camel.spring.spi.SpringTransactionPolicy">
<property name="transactionManager"
ref="txManager"/>
<property name="propagationBehaviorName"
value="PROPAGATION_REQUIRED"/>
</bean>
@@ -405,9 +263,7 @@ from("mybatis:selectUnprocessedAcco
</route>
</camelContext>
]]></script>
-</div></div>
-
-<h3 id="MyBatis-SeeAlso">See Also</h3>
+</div></div><p></p><h3 id="MyBatis-SeeAlso">See Also</h3>
<ul><li><a shape="rect" href="configuring-camel.html">Configuring
Camel</a></li><li><a shape="rect"
href="component.html">Component</a></li><li><a shape="rect"
href="endpoint.html">Endpoint</a></li><li><a shape="rect"
href="getting-started.html">Getting Started</a></li></ul></div>
</td>
<td valign="top">