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 2020/09/03 06:49:50 UTC

[camel-kafka-connector-examples] branch rabbitmq-example created (now 452208f)

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

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


      at 452208f  Added RabbitMQ Sink examples

This branch includes the following new commits:

     new 452208f  Added RabbitMQ Sink examples

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[camel-kafka-connector-examples] 01/01: Added RabbitMQ Sink examples

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 452208fedd0e86e7d1678de114c27261fd5c81a6
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Sep 3 08:48:19 2020 +0200

    Added RabbitMQ Sink examples
---
 rabbitmq/rabbitmq-sink/README.adoc                 | 103 +++++++++++++++++++++
 .../config/CamelRabbitmqSinkConnector.properties   |  33 +++++++
 2 files changed, 136 insertions(+)

diff --git a/rabbitmq/rabbitmq-sink/README.adoc b/rabbitmq/rabbitmq-sink/README.adoc
new file mode 100644
index 0000000..c379a73
--- /dev/null
+++ b/rabbitmq/rabbitmq-sink/README.adoc
@@ -0,0 +1,103 @@
+# Camel-Kafka-connector RabbitMQ Sink
+
+## Introduction
+
+This is an example for Camel-Kafka-connector RabbitMQ
+
+## What is needed
+
+- A RabbitMQ instance
+
+## Running Kafka
+
+```
+$KAFKA_HOME/bin/zookeeper-server-start.sh config/zookeeper.properties
+$KAFKA_HOME/bin/kafka-server-start.sh 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/oscerd/connectors/`
+
+```
+> cd /home/oscerd/connectors/
+> wget https://repo1.maven.org/maven2/org/apache/camel/kafkaconnector/camel-rabbitmq-kafka-connector/0.4.0/camel-rabbitmq-kafka-connector-0.4.0-package.zip
+> unzip camel-rabbitmq-kafka-connector-0.4.0-package.zip
+```
+
+## Setting up Apache Cassandra
+
+This examples require a running RabbitMQ instance, for simplicity the steps below show how to start RabbitMQ using Docker. First you'll need to run a RabbitMQ with management instance:
+
+[source,bash]
+----
+docker run -d --hostname my-rabbit --name some-rabbit rabbitmq:3-management
+----
+
+Next, we need to check the address of the container
+
+[source,bash]
+----
+> docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' container_id
+172.17.0.2
+----
+
+In the configuration `.properties` file we use below the IP address of the RabbitMQ master node needs to be configured, replace the value `172.17.0.2` configuration property with the IP of the node obtained from Docker. 
+
+Next through your browser go to http://<address>:15672
+and login with the credentials guest/guest
+
+Create a queue called 'queue'.
+
+Now it's time to setup the connectors
+
+Open the RabbitMQ Sink configuration file
+
+```
+name=CamelRabbitmqSinkConnector
+connector.class=org.apache.camel.kafkaconnector.rabbitmq.CamelRabbitmqSinkConnector
+key.converter=org.apache.kafka.connect.storage.StringConverter
+value.converter=org.apache.kafka.connect.storage.StringConverter
+
+topics=mytopic
+
+camel.component.rabbitmq.hostname=172.17.0.2
+camel.component.rabbitmq.portnumber=5672
+camel.sink.path.exchangeName=queue
+camel.sink.endpoint.exchangeType=topic
+camel.sink.endpoint.autoDelete=false
+camel.sink.endpoint.queue=queue
+camel.sink.endpoint.routingKey=key
+```
+
+Now you can run the example
+
+```
+$KAFKA_HOME/bin/connect-standalone.sh $KAFKA_HOME/config/connect-standalone.properties config/CamelRabbitmqSinkConnector.properties
+```
+
+On a different terminal run the kafka-producer and you should see messages from Kafka arriving at RabbitMQ
+
+```
+bin/kafka-console-producer.sh --topic mytopic --broker-list localhost:9092
+>test
+>test1
+>test2
+>test3
+```
+
+At this point you should be able to get messages through the management console, so these are the steps needed:
+
+- Go to http://<address>:15672
+- Select the Queues tab
+- Select the 'queue' Queue
+- Select get Messages action
+- Browse through the messages
+
diff --git a/rabbitmq/rabbitmq-sink/config/CamelRabbitmqSinkConnector.properties b/rabbitmq/rabbitmq-sink/config/CamelRabbitmqSinkConnector.properties
new file mode 100644
index 0000000..f94f73a
--- /dev/null
+++ b/rabbitmq/rabbitmq-sink/config/CamelRabbitmqSinkConnector.properties
@@ -0,0 +1,33 @@
+#
+# 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=CamelRabbitmqSinkConnector
+connector.class=org.apache.camel.kafkaconnector.rabbitmq.CamelRabbitmqSinkConnector
+key.converter=org.apache.kafka.connect.storage.StringConverter
+value.converter=org.apache.kafka.connect.storage.StringConverter
+
+topics=mytopic
+
+camel.component.rabbitmq.hostname=172.17.0.2
+camel.component.rabbitmq.portnumber=5672
+camel.sink.path.exchangeName=queue
+camel.sink.endpoint.exchangeType=topic
+camel.sink.endpoint.autoDelete=false
+camel.sink.endpoint.queue=queue
+camel.sink.endpoint.routingKey=key
+
+