Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions components/camel-couchbase/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Camel-couchbase
===============

This is a Couchbase component for Camel. Codebase is very similar to camel-couchdb component.

How to build the code
=====================

To build this project use

mvn install

For more help see the Apache Camel documentation:

http://camel.apache.org/writing-components.html
70 changes: 70 additions & 0 deletions components/camel-couchbase/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.apache.camel</groupId>
<artifactId>components</artifactId>
<version>2.13-SNAPSHOT</version>
</parent>

<artifactId>camel-couchbase</artifactId>
<packaging>bundle</packaging>
<name>Camel :: Couchbase</name>
<description>Camel Couchbase component</description>

<properties>
<camel.osgi.export.pkg>org.apache.camel.component.couchbase.*</camel.osgi.export.pkg>
<camel.osgi.export.service>org.apache.camel.spi.ComponentResolver;component=couchbase</camel.osgi.export.service>
</properties>

<dependencies>

<dependency>
<groupId>com.couchbase.client</groupId>
<artifactId>couchbase-client</artifactId>
<version>${couchbase-client-version}</version>
</dependency>

<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>

</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.camel.component.couchbase;

import org.apache.camel.CamelContext;
import org.apache.camel.impl.DefaultComponent;

import java.util.Map;

public class CouchbaseComponent extends DefaultComponent {

public CouchbaseComponent() {

}

public CouchbaseComponent(CamelContext context) {
super(context);
}

@Override
protected CouchbaseEndpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
CouchbaseEndpoint endpoint = new CouchbaseEndpoint(uri, remaining, this);
setProperties(endpoint, parameters);
return endpoint;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.camel.component.couchbase;

public interface CouchbaseConstants {

static String COUCHBASE_URI_ERROR = "Invalid URI. Format must be of the form couchbase:http[s]://hostname[:port]/bucket?[options...]";
static String COUCHBASE_PUT = "CCB_PUT";
static String COUCHBASE_GET = "CCB_GET";
static String COUCHBASE_DELETE = "CCB_DEL";
static String DEFAULT_DESIGN_DOCUMENT_NAME = "beer";
static String DEFAULT_VIEWNAME = "brewery_beers";
static String HEADER_KEY = "CCB_KEY";
static String HEADER_ID = "CCB_ID";
static String HEADER_DESIGN_DOCUMENT_NAME = "CCB_DDN";
static String HEADER_VIEWNAME = "CCB_VN";

static int COUCHBASE_DEFAULT_PORT = 8091;
static long DEFAULT_OP_TIMEOUT = 2500;
static int DEFAULT_TIMEOUT_EXCEPTION_THRESHOLD = 998;
static int DEFAULT_READ_BUFFER_SIZE = 16384;
static long DEFAULT_OP_QUEUE_MAX_BLOCK_TIME = 10000;
static long DEFAULT_MAX_RECONNECT_DELAY = 30000;
static long DEFAULT_OBS_POLL_INTERVAL = 400;
static long DEFAULT_OBS_TIMEOUT = -1;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.camel.component.couchbase;

import com.couchbase.client.CouchbaseClient;
import org.apache.camel.Processor;
import org.apache.camel.impl.DefaultConsumer;

import java.util.concurrent.ExecutorService;

public class CouchbaseConsumer extends DefaultConsumer {

private final CouchbaseEndpoint endpoint;
private final CouchbaseClient client;
private ExecutorService executor;
private CouchbaseReceiver task;


public CouchbaseConsumer(CouchbaseEndpoint endpoint, CouchbaseClient client, Processor processor) {
super(endpoint, processor);
this.client = client;
this.endpoint = endpoint;
}

@Override
protected void doStart() throws Exception {
super.doStart();
log.info("Starting Couchbase consumer");

executor = endpoint.getCamelContext().getExecutorServiceManager().newFixedThreadPool(this, endpoint.getEndpointUri(), 1);
task = new CouchbaseReceiver(endpoint, this, client);
executor.submit(task);
}

@Override
protected void doStop() throws Exception {
super.doStop();
log.info("Stopping Couchbase consumer");
if (task != null) {
task.stop();
}
if (executor != null) {
endpoint.getCamelContext().getExecutorServiceManager().shutdownNow(executor);
executor = null;
}
}

}

Loading