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:06:43 UTC

[camel-kafka-connector-examples] branch rabbitmq-example created (now 078a43f)

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 078a43f  Added a RabbitMQ example

This branch includes the following new commits:

     new 078a43f  Added a RabbitMQ example

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 a RabbitMQ example

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 078a43f0a882d66d8e634b50dadd4eb3665db253
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Sep 3 08:04:21 2020 +0200

    Added a RabbitMQ example
---
 rabbitmq/rabbitmq-source/README.adoc               | 101 +++++++++++++++++++++
 .../config/CamelRabbitmqSourceConnector.properties |  35 +++++++
 2 files changed, 136 insertions(+)

diff --git a/rabbitmq/rabbitmq-source/README.adoc b/rabbitmq/rabbitmq-source/README.adoc
new file mode 100644
index 0000000..f50d28a
--- /dev/null
+++ b/rabbitmq/rabbitmq-source/README.adoc
@@ -0,0 +1,101 @@
+# Camel-Kafka-connector CQL Source
+
+## 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 Source configuration file
+
+```
+name=CamelRabbitmqSourceConnector
+connector.class=org.apache.camel.kafkaconnector.rabbitmq.CamelRabbitmqSourceConnector
+key.converter=org.apache.kafka.connect.storage.StringConverter
+value.converter=org.apache.kafka.connect.converters.ByteArrayConverter
+
+camel.source.maxPollDuration=10000
+
+topics=mytopic
+
+camel.component.rabbitmq.hostname=172.17.0.2
+camel.component.rabbitmq.portnumber=5672
+camel.source.path.exchangeName=queue
+camel.source.endpoint.exchangeType=topic
+camel.source.endpoint.autoDelete=false
+camel.source.endpoint.queue=queue
+camel.source.endpoint.routingKey=key
+```
+
+Now you can run the example
+
+```
+$KAFKA_HOME/bin/connect-standalone.sh $KAFKA_HOME/config/connect-standalone.properties config/CamelRabbitmqSourceConnector.properties
+```
+
+At this point you should be able to publish messages through the management console, so these are the steps needed:
+
+- Go to http://<address>:15672
+- Select the Queues tab
+- Select the 'queue' Queue
+- Publish message with body "Hello"
+
+On a different terminal run the kafka-consumer and you should see messages to Kafka from RabbitMQ
+
+```
+bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic mytopic --from-beginning
+Hello
+```
+
diff --git a/rabbitmq/rabbitmq-source/config/CamelRabbitmqSourceConnector.properties b/rabbitmq/rabbitmq-source/config/CamelRabbitmqSourceConnector.properties
new file mode 100644
index 0000000..510196c
--- /dev/null
+++ b/rabbitmq/rabbitmq-source/config/CamelRabbitmqSourceConnector.properties
@@ -0,0 +1,35 @@
+#
+# 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=CamelRabbitmqSourceConnector
+connector.class=org.apache.camel.kafkaconnector.rabbitmq.CamelRabbitmqSourceConnector
+key.converter=org.apache.kafka.connect.storage.StringConverter
+value.converter=org.apache.kafka.connect.converters.ByteArrayConverter
+
+camel.source.maxPollDuration=10000
+
+topics=mytopic
+
+camel.component.rabbitmq.hostname=172.17.0.2
+camel.component.rabbitmq.portnumber=5672
+camel.source.path.exchangeName=queue
+camel.source.endpoint.exchangeType=topic
+camel.source.endpoint.autoDelete=false
+camel.source.endpoint.queue=queue
+camel.source.endpoint.routingKey=key
+
+