diff --git a/connectors/activemq-sink/2.5.1/activemq-sink.md b/connectors/activemq-sink/2.5.1/activemq-sink.md deleted file mode 100644 index f035e0bcc..000000000 --- a/connectors/activemq-sink/2.5.1/activemq-sink.md +++ /dev/null @@ -1,181 +0,0 @@ ---- -description: The ActiveMQ sink connector pulls messages from Pulsar topics and persist messages to ActiveMQ clusters. -author: ["ASF"] -contributors: ["ASF"] -language: Java -document: -source: "https://github.com/streamnative/pulsar-io-activemq/tree/v2.5.1" -license: Apache License 2.0 -tags: ["Pulsar IO", "ActiveMQ", "Sink"] -alias: ActiveMQ Sink -features: ["Use ActiveMQ sink connector to sync data from Pulsar"] -license_link: "https://www.apache.org/licenses/LICENSE-2.0" -icon: "/images/connectors/activemq_logo_white_vertical.jpg" -download: "https://github.com/streamnative/pulsar-io-activemq/releases/download/v2.5.1/pulsar-io-activemq-2.5.1.nar" -support: StreamNative -support_link: https://streamnative.io -support_img: "/images/connectors/streamnative.png" -dockerfile: -owner_name: "StreamNative" -owner_img: "/images/streamnative.png" -id: "activemq-sink" ---- - -The ActiveMQ sink connector pulls messages from Pulsar topics and persist messages to ActiveMQ clusters. - -# Installation - -To install the ActiveMQ sink connector, follow these steps. - -1. Download the NAR package of the ActiveMQ sink connector from [here](https://github.com/streamnative/pulsar-io-activemq/releases/download/v2.5.1/pulsar-io-activemq-2.5.1.nar). - -2. Put the NAR package `pulsar-io-activemq-2.5.1.nar` in the pulsar connectors catalog. - - ``` - cp pulsar-io-activemq-2.5.1.nar $PULSAR_HOME/connectors/pulsar-io-activemq-2.5.1.nar - ``` - -3. Start Pulsar in standalone mode. - - ``` - $PULSAR_HOME/bin/pulsar standalone - ``` - -4. Run the ActiveMQ sink connector locally. - - ``` - $PULSAR_HOME/bin/pulsar-admin sink localrun --sink-config-file activemq-sink-config.yaml - ``` - -# Configuration - -The configuration of the ActiveMQ sink connector has the following properties. - -## ActiveMQ sink connector configuration - -| Name | Type|Required | Default | Description -|------|----------|----------|---------|-------------| -| `protocol` |String| true | "tcp" | ActiveMQ protocol | -| `host` | String| true | " " (empty string) | ActiveMQ host | -| `port` | int |true | 5672 | ActiveMQ port | -| `username` | String|false | " " (empty string) | Username used to authenticate to ActiveMQ | -| `password` | String|false | " " (empty string) | Password used to authenticate to ActiveMQ | -| `queueName` | String|false | " " (empty string) | ActiveMQ queue name that messages should be read from or written to | -| `topicName` | String|false | " " (empty string) | ActiveMQ topic name that messages should be read from or written to | -| `activeMessageType` | String|false |0 | ActiveMQ message simple class name | - -## Configure ActiveMQ sink connector - -Before using the ActiveMQ sink connector, you need to create a configuration file through one of the following methods. - -* JSON - - ```json - { - "tenant": "public", - "namespace": "default", - "name": "activemq-sink", - "inputs": ["user-op-queue-topic"], - "archive": "connectors/pulsar-io-activemq-2.5.1.nar", - "parallelism": 1, - "configs": - { - "protocol": "tcp", - "host": "localhost", - "port": "61616", - "username": "admin", - "password": "admin", - "queueName": "user-op-queue-pulsar" - } - } - ``` - -* YAML - - ```yaml - tenant: "public" - namespace: "default" - name: "activemq-sink" - inputs: - - "user-op-queue-topic" - archive: "connectors/pulsar-io-activemq-2.5.1.nar" - parallelism: 1 - - configs: - protocol: "tcp" - host: "localhost" - port: "61616" - username: "admin" - password: "admin" - queueName: "user-op-queue-pulsar" - ``` - -# Usage - -This section describes how to use the ActiveMQ sink connector to pull messages from Pulsar topics to ActiveMQ clusters. - -1. Prepare ActiveMQ service. - - ``` - docker pull rmohr/activemq - docker run -p 61616:61616 -p 8161:8161 rmohr/activemq - ``` - -2. Put the `pulsar-io-activemq-2.5.1.nar` in the pulsar connectors catalog. - - ``` - cp pulsar-io-activemq-2.5.1.nar $PULSAR_HOME/connectors/pulsar-io-activemq-2.5.1.nar - ``` - -3. Start Pulsar in standalone mode. - - ``` - $PULSAR_HOME/bin/pulsar standalone - ``` - -4. Run ActiveMQ sink locally. - - ``` - $PULSAR_HOME/bin/pulsar-admin sink localrun --sink-config-file activemq-sink-config.yaml - ``` - -5. Send Pulsar messages. - - ``` - $PULSAR_HOME/bin/pulsar-client produce public/default/user-op-queue-topic --messages hello -n 10 - ``` - -6. Consume ActiveMQ messages. - - Use the test method `receiveMessage` of the class `org.apache.pulsar.ecosystem.io.activemq.ActiveMQDemo` -to consume ActiveMQ messages. - - ```java - public void receiveMessage() throws JMSException, InterruptedException { - ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616"); - - @Cleanup - Connection connection = connectionFactory.createConnection(); - connection.start(); - - @Cleanup - Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - Destination destination = session.createQueue("user-op-queue-pulsar"); - - @Cleanup - MessageConsumer consumer = session.createConsumer(destination); - CountDownLatch countDownLatch = new CountDownLatch(10); - consumer.setMessageListener(message -> { - if (message instanceof ActiveMQTextMessage) { - try { - System.out.println("get message ----------------- "); - System.out.println("receive: " + ((ActiveMQTextMessage) message).getText()); - } catch (JMSException e) { - e.printStackTrace(); - } - countDownLatch.countDown(); - } - }); - countDownLatch.await(); - } - ``` \ No newline at end of file diff --git a/connectors/activemq-sink/io-activemq-sink.yaml b/connectors/activemq-sink/io-activemq-sink.yaml new file mode 100644 index 000000000..fb527c043 --- /dev/null +++ b/connectors/activemq-sink/io-activemq-sink.yaml @@ -0,0 +1,2 @@ +repository: https://github.com/streamnative/pulsar-io-activemq +icon: "/images/connectors/activemq_logo_white_vertical.jpg" \ No newline at end of file diff --git a/connectors/activemq-source/2.5.1/activemq-source.md b/connectors/activemq-source/2.5.1/activemq-source.md deleted file mode 100644 index 65ef5d5be..000000000 --- a/connectors/activemq-source/2.5.1/activemq-source.md +++ /dev/null @@ -1,175 +0,0 @@ ---- -description: The ActiveMQ source connector receives messages from ActiveMQ clusters and writes messages to Pulsar topics. -author: ["ASF"] -contributors: ["ASF"] -language: Java -document: -source: "https://github.com/streamnative/pulsar-io-activemq/tree/v2.5.1" -license: Apache License 2.0 -tags: ["Pulsar IO", "ActiveMQ", "Source"] -alias: ActiveMQ Source -features: ["Use ActiveMQ source connector to sync data to Pulsar"] -license_link: "https://www.apache.org/licenses/LICENSE-2.0" -icon: "/images/connectors/activemq_logo_white_vertical.jpg" -download: "https://github.com/streamnative/pulsar-io-activemq/releases/download/v2.5.1/pulsar-io-activemq-2.5.1.nar" -support: StreamNative -support_link: https://streamnative.io -support_img: "/images/connectors/streamnative.png" -dockerfile: -owner_name: "StreamNative" -owner_img: "/images/streamnative.png" -id: "activemq-source" ---- - -The ActiveMQ source connector receives messages from ActiveMQ clusters and writes messages to Pulsar topics. - -# Installation - -To install the ActiveMQ source connector, follow these steps. - -1. Download the NAR package of the ActiveMQ source connector from [here](https://github.com/streamnative/pulsar-io-activemq/releases/download/v2.5.1/pulsar-io-activemq-2.5.1.nar). - -2. Put the NAR package `pulsar-io-activemq-2.5.1.nar` in the pulsar connectors catalog. - - ``` - cp pulsar-io-activemq-2.5.1.nar $PULSAR_HOME/connectors/pulsar-io-activemq-2.5.1.nar - ``` - -3. Start Pulsar in standalone mode. - - ``` - $PULSAR_HOME/bin/pulsar standalone - ``` - -4. Run the ActiveMQ source connector locally. - - ``` - $PULSAR_HOME/bin/pulsar-admin source localrun --source-config-file activemq-source-config.yaml - ``` - -# Configuration - -The configuration of the ActiveMQ source connector has the following properties. - -## ActiveMQ source connector configuration - -| Name | Type|Required | Default | Description -|------|----------|----------|---------|-------------| -| `protocol` |String| true | "tcp" | ActiveMQ protocol | -| `host` | String| true | " " (empty string) | ActiveMQ host | -| `port` | int |true | 5672 | ActiveMQ port. | -| `username` | String|false | " " (empty string) | Username used to authenticate to ActiveMQ | -| `password` | String|false | " " (empty string) | Password used to authenticate to ActiveMQ. | -| `queueName` | String|false | " " (empty string) | ActiveMQ queue name that messages should be read from or written to | -| `topicName` | String|false | " " (empty string) | ActiveMQ topic name that messages should be read from or written to | - -## Configure ActiveMQ source connector - -Before using the ActiveMQ source connector, you need to create a configuration file through one of the following methods. - -* JSON - - ```json - { - "tenant": "public", - "namespace": "default", - "name": "activemq-source", - "topicName": "user-op-queue-topic", - "archive": "connectors/pulsar-io-activemq-2.5.1.nar", - "parallelism": 1, - "configs": { - "protocol": "tcp", - "host": "localhost", - "port": "61616", - "username": "admin", - "password": "admin", - "queueName": "user-op-queue" - } - } - ``` - -* YAML - - ```yaml - tenant: "public" - namespace: "default" - name: "activemq-source" - topicName: "user-op-queue-topic" - archive: "connectors/pulsar-io-activemq-2.5.1.nar" - parallelism: 1 - - configs: - protocol: "tcp" - host: "localhost" - port: "61616" - username: "admin" - password: "admin" - queueName: "user-op-queue" - ``` - -# Usage - -This example shows how to use the ActiveMQ source connector to receive messages from ActiveMQ clusters and writes messages to Pulsar topics. - -1. Prepare ActiveMQ service. - - ``` - docker pull rmohr/activemq - docker run -p 61616:61616 -p 8161:8161 rmohr/activemq - ``` - -2. Put the `pulsar-io-activemq-2.5.1.nar` in the pulsar connectors catalog. - - ``` - cp pulsar-io-activemq-2.5.1.nar $PULSAR_HOME/connectors/pulsar-io-activemq-2.5.1.nar - ``` - -3. Start Pulsar in standalone mode. - - ``` - $PULSAR_HOME/bin/pulsar standalone - ``` - -4. Run ActiveMQ source locally. - - ``` - $PULSAR_HOME/bin/pulsar-admin source localrun --source-config-file activemq-source-config.yaml - ``` - -5. Consume Pulsar messages. - - ``` - $PULSAR_HOME/bin/pulsar-client consume -s "sub-products" public/default/user-op-queue-topic -n 0 - ``` - -6. Send ActiveMQ messages. - - Use the test method `sendMessage` of the `class org.apache.pulsar.ecosystem.io.activemq.ActiveMQDemo` -to send ActiveMQ messages. - - ```java - public void sendMessage() throws JMSException { - - ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616"); - - @Cleanup - Connection connection = connectionFactory.createConnection(); - connection.start(); - - @Cleanup - Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE); - - Destination destination = session.createQueue("user-op-queue"); - - @Cleanup - MessageProducer producer = session.createProducer(destination); - producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT); - - for (int i = 0; i < 10; i++) { - String msgContent = "Hello ActiveMQ - " + i; - ActiveMQTextMessage message = new ActiveMQTextMessage(); - message.setText(msgContent); - producer.send(message); - } - } - ``` \ No newline at end of file diff --git a/connectors/activemq-source/io-activemq-source.yaml b/connectors/activemq-source/io-activemq-source.yaml new file mode 100644 index 000000000..fb527c043 --- /dev/null +++ b/connectors/activemq-source/io-activemq-source.yaml @@ -0,0 +1,2 @@ +repository: https://github.com/streamnative/pulsar-io-activemq +icon: "/images/connectors/activemq_logo_white_vertical.jpg" \ No newline at end of file