camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Camel > CouchDB
Date Sat, 25 Aug 2012 23:31:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/2042/9/1/_/styles/combined.css?spaceKey=CAMEL&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/CAMEL/CouchDB">CouchDB</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~samspade79@gmail.com">stephen
samuel</a>
    </h4>
        <br/>
                         <h4>Changes (4)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >| {{deletes}} | {{true}} | document
deletes are published as events | <br>| {{updates}} | {{true}} | document inserts/updates
are published as events | <br></td></tr>
            <tr><td class="diff-changed-lines" >| {{heartbeat}} | <span class="diff-changed-words"><span
class="diff-added-chars"style="background-color: #dfd;">{{</span>30000<span class="diff-added-chars"style="background-color:
#dfd;">}}</span></span> | how often to send an empty message to keep socket
alive in millis | <br></td></tr>
            <tr><td class="diff-changed-lines" >| {{createDatabase}} | <span
class="diff-changed-words">{{true}<span class="diff-added-chars"style="background-color:
#dfd;">}</span></span> | create the database if it does not already exist |
<br></td></tr>
            <tr><td class="diff-changed-lines" >| {{username}} | <span class="diff-added-words"style="background-color:
#dfd;">{{null}}</span> | username in case of authenticated databases | <br></td></tr>
            <tr><td class="diff-changed-lines" >| {{password}} | <span class="diff-added-words"style="background-color:
#dfd;">{{null}}</span> | password for authenticated databases | <br></td></tr>
            <tr><td class="diff-unchanged" >{div} <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h2><a name="CouchDB-CamelCouchDBcomponent"></a>Camel CouchDB component</h2>

<p><b>Available as of Camel 2.11</b></p>

<p>The <b>couchdb:</b> component allows you to treat <a href="http://couchdb.apache.org/"
class="external-link" rel="nofollow">CouchDB</a> instances as a producer or consumer
of messages. Using the lightweight LightCouch API, this camel component has the following
features:</p>

<ul>
	<li>As a consumer, monitors couch changesets for inserts, updates and deletes and publishes
these as messages into camel routes.</li>
	<li>As a producer, can save or update documents into couch.</li>
	<li>Can support as many endpoints as required, eg for multiple databases across multiple
instances.</li>
	<li>Ability to have events trigger for only deletes, only inserts/updates or all (default).</li>
	<li>Headers set for sequenceId, document revision, document id, and HTTP method type.</li>
</ul>


<p>Maven users will need to add the following dependency to their <tt>pom.xml</tt>
for this component:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;dependency&gt;</span>
    <span class="code-tag">&lt;groupId&gt;</span>org.apache.camel<span
class="code-tag">&lt;/groupId&gt;</span>
    <span class="code-tag">&lt;artifactId&gt;</span>camel-couchdb<span
class="code-tag">&lt;/artifactId&gt;</span>
    <span class="code-tag">&lt;version&gt;</span>x.x.x<span class="code-tag">&lt;/version&gt;</span>
    <span class="code-tag"><span class="code-comment">&lt;!-- use the same
version as your Camel core version --&gt;</span></span>
<span class="code-tag">&lt;/dependency&gt;</span>
</pre>
</div></div>

<h3><a name="CouchDB-URIformat"></a>URI format</h3>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
couchdb:http:<span class="code-comment">//hostname[:port]/database?[options...]://name[?options]</span>
</pre>
</div></div>

<p>Where <b>hostname</b> is the hostname of the running couchdb instance.
Port is optional and if not specified then defaults to 5984.</p>

<h3><a name="CouchDB-Options"></a>Options</h3>
<div class="confluenceTableSmall"><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Property </th>
<th class='confluenceTh'> Default </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>deletes</tt> </td>
<td class='confluenceTd'> <tt>true</tt> </td>
<td class='confluenceTd'> document deletes are published as events </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>updates</tt> </td>
<td class='confluenceTd'> <tt>true</tt> </td>
<td class='confluenceTd'> document inserts/updates are published as events </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>heartbeat</tt> </td>
<td class='confluenceTd'> <tt>30000</tt> </td>
<td class='confluenceTd'> how often to send an empty message to keep socket alive in
millis </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>createDatabase</tt> </td>
<td class='confluenceTd'> <tt>true</tt> </td>
<td class='confluenceTd'> create the database if it does not already exist </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>username</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> username in case of authenticated databases </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>password</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> password for authenticated databases </td>
</tr>
</tbody></table>
</div>
</div>

<h3><a name="CouchDB-Headers"></a>Headers</h3>

<p>The following headers are set on exchanges during message transport.</p>
<div class="confluenceTableSmall"><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Property </th>
<th class='confluenceTh'> Value </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>CouchDbDatabase</tt> </td>
<td class='confluenceTd'> the database the message came from </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CouchDbSeq</tt> </td>
<td class='confluenceTd'> the couchdb changeset sequence number of the update / delete
message </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CouchDbId</tt> </td>
<td class='confluenceTd'> the couchdb document id </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CouchDbRev</tt> </td>
<td class='confluenceTd'> the couchdb document revision </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CouchDbMethod</tt> </td>
<td class='confluenceTd'> the method (delete / update) </td>
</tr>
</tbody></table>
</div>
</div>

<h3><a name="CouchDB-Samples"></a>Samples</h3>

<p>For example if you wish to consume all inserts, updates and deletes from a CouchDB
instance running locally, on port 9999 then you could use the following:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"couchdb:http:<span class="code-comment">//localhost:9999"</span>).process(someProcessor);</span>
</pre>
</div></div>

<p>If you were only interested in deletes, then you could use the following</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"couchdb:http:<span class="code-comment">//localhost:9999?updates=<span
class="code-keyword">false</span>"</span>).process(someProcessor);</span>
</pre>
</div></div>

<p>If you wanted to insert a message as a document, then the body of the exchange is
used</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"someProducingEndpoint"</span>).process(someProcessor).to(<span
class="code-quote">"couchdb:http:<span class="code-comment">//localhost:9999"</span>)</span>
</pre>
</div></div>
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/CouchDB">View Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=30148793&revisedVersion=5&originalVersion=4">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/CouchDB?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message