You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Current »

Available as of Camel Extra 2.13

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

<dependency>
  <groupId>org.apache-extras.camel-extra</groupId>
  <artifactId>camel-couchbase</artifactId>
  <version>x.x.x</version>
  <!-- use the same version as your Camel core version -->
</dependency>

URI format

couchbase:http[s]://hostname/bucket?[options]

URI options

NameDefault ValueTypeContextDescription
additionalHosts""StringSharedComma separated list of additional hostnames
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)
producerRetryAttempts2intProducerNumber of retries
producerRetryPause5000intProducerPause between retries (in ms)
persistTo0intProducer

0: Don't wait for persistence on any nodes.

1: Persist to Master.

2: Persist to at least two nodes including Master.

3: Persist to at least three nodes including Master.

4: Persist to at least four nodes including Master.

replicateTo0intProducer

0: Don't replicate.

1: Replicate to at least one node.

2: Replicate to at least two nodes.

3: Replicate to at least three nodes.

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_KEYnullStringSharedKey of the consumed row
CCB_IDnullStringConsumerId of the consumed row
CCB_DDNnullStringConsumerDocument Design name
CCB_VNnullStringConsumerView Name
CCB_TTL0intProducerTTL of the document

Example

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

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:

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:

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

 

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