Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Initial version

...

The camel-couchbase component supports the interaction to the NoSQL document database Couchbase via the couchbase-client library. Couchbase is an high performance Document Store very easy to scale out, which supports topology changes with no downtime

Dependency

Code Block
xml
xml
<dependency>
  <groupId>org.apache-extras.camel-extra</groupId>
  <artifactId>camel-couchbase</artifactId>
  <version>2.13.0</version>
</dependency>

URI format

Code Block
couchbase:protocolhttp[s]://host[:port]/buckethostname/bucket?[options]

URI options

NameDefault ValueTypeContextDescription
designDocumentName"beer"StringConsumerThe Document Design name, defaults to the beer example distributed with Couchbase
viewName"brewery_beers"StringConsumerThe Document view name, defaults, to the beer example distributed with Couchbase
limit-1intConsumerLimit the number of results that should be returned, default is unlimited
descendingfalsebooleanConsumerRevert the sorting order of the result set.
skip0intConsumerNumber of results to skip
rangeStartKey""StringConsumerStart Key to return records in the given key range.
rangeEndKey""StringConsumerEnd Key to return records in the given key range.
consumerProcessedStrategynoneStringConsumer

The strategy applied with consumed documents

none = consumed documents are untouched, you should beware of duplicates (f.e. use an idempotent receiver)

delete = consumed documents are deleted

operationPUTStringProducerThe operation to perform, currently supports the following values: PUT, DELETE, GET
autoStartIdForInsertsfalsebooleanProducerIf set to true, document id will be automatically generated
startingIdForInsertsFrom0intProducerStarting value for the document id (if autoStartIdForInserts == true)
username""StringSharedUsername
password""StringSharedPassword

More URI options

Following URI options control how the CouchbaseConnectionFactoryBuilder instantiates the connection. Every option defaults to couchbase-client defaults.

NameDefault ValueTypeContextDescription
opTimeOut2500intSharedTime in milliseconds for an operation to time out
timeoutExceptionThreshold998intSharedNumber of operations to time out before the node is deemed down
readBufferSize16384intSharedRead buffer size
maxReconnectDelay30000intSharedMaximum number of milliseconds to wait between reconnect attempts.
shouldOptimizefalsebooleanSharedOptimize behavior for the network
opQueueMaxBlockTime10000intSharedThe maximum time to block waiting for op queue operations to complete, in milliseconds.
obsPollInterval400intSharedWait for the specified interval before the observe operation polls the nodes.
obsTimeout -1intSharedObserve operation timeout

Message Headers

NameDefault ValueTypeContextDescription
CCB_KEYnullStringConsumerKey of the consumed row
CCB_IDnullStringConsumerId of the consumed row
CCB_DDNnullStringConsumerDocument Design name
CCB_VNnullStringConsumerView Name

Example

Consume 10 documents from "beer-sample" bucket using Design Document "beer" and View "brewery_beers":

Code Block
languagejava
from("couchbase:http://localhost/beer-sample?designDocumentName=beer&viewName=brewery_beers&limit=10")
.to("mock:result");

 

Add a document with ID "12346" to "default" bucket:

Code Block
languagejava
from("direct:start")
.setHeader(CouchbaseConstants.HEADER_ID, constant("123456"))
.to("couchbase:http://localhost/default");

 

Add documents to default bucket automatically generating ids, starting from 1000:

Code Block
languagejava
from("direct:start")
                        .to("couchbase:http://localhost/default?autoStartIdForInserts=true&startingIdForInsertsFrom=1000")

 

Delete document with ID "120770" from "default" bucket:
Code Block
languagejava
from("direct:start")
                        .setHeader(CouchbaseConstants.HEADER_ID, constant("120770"))
                        .to("couchbase:http://localhost/default?operation='DELETE'")