You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2021/01/19 08:17:14 UTC

[camel-kafka-connector-examples] branch master updated: Added a simple Couchbase example

This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-kafka-connector-examples.git


The following commit(s) were added to refs/heads/master by this push:
     new 6a81ed1  Added a simple Couchbase example
6a81ed1 is described below

commit 6a81ed1928bdafc3e0cacdf3ec7e2ca7777d0b1f
Author: Otavio Rodolfo Piske <op...@redhat.com>
AuthorDate: Mon Jan 18 11:07:42 2021 +0100

    Added a simple Couchbase example
---
 couchbase/couchbase-sink/README.adoc               | 110 +++++++++++++++++++++
 .../config/CamelCouchbaseSinkConnector.properties  |  27 +++++
 2 files changed, 137 insertions(+)

diff --git a/couchbase/couchbase-sink/README.adoc b/couchbase/couchbase-sink/README.adoc
new file mode 100644
index 0000000..07330c1
--- /dev/null
+++ b/couchbase/couchbase-sink/README.adoc
@@ -0,0 +1,110 @@
+# Camel-Kafka-connector Couchbase Sink
+
+## Introduction
+
+This is an example for Camel-Kafka-connector Couchbase.The support for Couchbase is *experimental* at
+this moment.
+
+## What is needed
+
+- A Couchbase instance
+
+## Running Kafka
+
+```
+$KAFKA_HOME/bin/zookeeper-server-start.sh $KAFKA_HOME/config/zookeeper.properties
+$KAFKA_HOME/bin/kafka-server-start.sh $KAFKA_HOME/config/server.properties
+$KAFKA_HOME/bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic mytopic
+```
+
+## Setting up the needed bits and running the example
+
+You'll need to setup the plugin.path property in your kafka
+
+Open the `$KAFKA_HOME/config/connect-standalone.properties`
+
+and set the `plugin.path` property to your choosen location
+
+In this example we'll use `/home/otavio/connectors/`
+
+```
+> cd /home/otavio/connectors/
+> wget https://repo1.maven.org/maven2/org/apache/camel/kafkaconnector/camel-couchbase-kafka-connector/0.7.0/camel-couchbase-kafka-connector-0.7.0-package.zip
+> unzip camel-couchbase-kafka-connector-0.7.0-package.zip
+```
+
+## Setting up Couchbase
+
+This examples require a running Couchbase instance, for simplicity the steps below show how to start Couchbase using
+Docker. We will use the community image, therefore Couchbase Enterprise features will not be available. First you'll
+need to run a Couchbase instance:
+
+[source,bash]
+----
+docker run --name couchbase -p 8091-8096:8091-8096 -p 11210-11211:11210-11211 couchbase/server:community-6.5.1
+----
+
+Next, access the Couchbase UI and proceed with the configuration.
+
+----
+http://couchbase-host:8091
+----
+
+Select "Setup New Cluster" and fill the form with the following values:
+
+|===
+| Field | Value
+
+| Cluster Name | exampleCluster
+| Create Admin UserName | Administrator
+| Create Password | MyPassword
+| Confirm Password | MyPassword
+|===
+
+Click on "Next: Accept Terms" to review the licensing conditions for using Couchbase. If satisfied
+with the terms and conditions, accept them and click on "Finish With Defaults".
+
+
+To create the bucket, you can use "Add Bucket" link on the UI or run the following command:
+
+[source,bash]
+----
+curl -u Administrator:MyPassword -v -X POST http://couchbase-host:8091/pools/default/buckets -d name=ExampleBucket -d ramQuotaMB=100
+----
+
+*Note*: replace `couchbase-host` with the actual host running Couchbase on the command above and
+all subsequent commands below.
+
+Now it's time to setup the connectors
+
+Open the Couchbase Sink configuration file
+
+```
+name=CamelCouchbaseSinkConnector
+
+connector.class=org.apache.camel.kafkaconnector.couchbase.CamelCouchbaseSinkConnector
+value.converter=org.apache.kafka.connect.storage.StringConverter
+key.converter=org.apache.kafka.connect.storage.StringConverter
+tasks.max=1
+
+topics=couchbase-sink-topic
+
+camel.sink.url=couchbase:http://couchbase-host:11210?bucket=ExampleBucket&username=Administrator&password=MyPassword&connectTimeout=5000&queryTimeout=5000&producerRetryAttempts=10&producerRetryPause=7500
+```
+
+Set the correct options in the file.
+
+Now you can run the example
+
+```
+$KAFKA_HOME/bin/connect-standalone.sh $KAFKA_HOME/config/connect-standalone.properties config/CamelCouchbaseSinkConnector.properties
+```
+
+On a different terminal run the kafka-producer and use it to populate Couchbase with messages
+
+```
+kafka-console-producer.sh --broker-list localhost:9092 --topic couchbase-sink-topic
+>message
+```
+You can verify the behavior by accessing Documents page on the Buckets package in the
+Couchbase UI.
\ No newline at end of file
diff --git a/couchbase/couchbase-sink/config/CamelCouchbaseSinkConnector.properties b/couchbase/couchbase-sink/config/CamelCouchbaseSinkConnector.properties
new file mode 100644
index 0000000..c735644
--- /dev/null
+++ b/couchbase/couchbase-sink/config/CamelCouchbaseSinkConnector.properties
@@ -0,0 +1,27 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+name=CamelCouchbaseSinkConnector
+
+connector.class=org.apache.camel.kafkaconnector.couchbase.CamelCouchbaseSinkConnector
+value.converter=org.apache.kafka.connect.storage.StringConverter
+key.converter=org.apache.kafka.connect.storage.StringConverter
+tasks.max=1
+
+topics=couchbase-sink-topic
+
+camel.sink.url=couchbase:http://couchbase-host:11210?bucket=ExampleBucket&username=Administrator&password=MyPassword&connectTimeout=5000&queryTimeout=5000&producerRetryAttempts=10&producerRetryPause=7500
\ No newline at end of file