From 7dab171d0f7b5570f0ee62886ee40c57e6d71698 Mon Sep 17 00:00:00 2001 From: Stanislav Knot Date: Wed, 18 Oct 2017 10:47:59 +0200 Subject: [PATCH] ARTEMIS-1467 example for bridging messages from the 5.x broker to Artemis --- .../sub-modules/artemis-jms-bridge/README.md | 93 ++++++++++++++++ .../activemq-artemis-camel/pom.xml | 101 ++++++++++++++++++ .../src/main/resources/bridge.xml | 67 ++++++++++++ .../src/main/webapp/WEB-INF/web.xml | 30 ++++++ .../artemis-jms-bridge/pom.xml | 99 +++++++++++++++++ .../bridge/ConnectionFactoryFactoryBean.java | 35 ++++++ .../bridge/DestinationFactoryBean.java | 36 +++++++ .../src/main/resources/bridge.xml | 69 ++++++++++++ .../src/main/webapp/WEB-INF/web.xml | 30 ++++++ .../sub-modules/artemis-jms-bridge/pom.xml | 64 +++++++++++ examples/features/sub-modules/pom.xml | 1 + 11 files changed, 625 insertions(+) create mode 100644 examples/features/sub-modules/artemis-jms-bridge/README.md create mode 100644 examples/features/sub-modules/artemis-jms-bridge/activemq-artemis-camel/pom.xml create mode 100644 examples/features/sub-modules/artemis-jms-bridge/activemq-artemis-camel/src/main/resources/bridge.xml create mode 100644 examples/features/sub-modules/artemis-jms-bridge/activemq-artemis-camel/src/main/webapp/WEB-INF/web.xml create mode 100644 examples/features/sub-modules/artemis-jms-bridge/artemis-jms-bridge/pom.xml create mode 100644 examples/features/sub-modules/artemis-jms-bridge/artemis-jms-bridge/src/main/java/org/artemis/bridge/ConnectionFactoryFactoryBean.java create mode 100644 examples/features/sub-modules/artemis-jms-bridge/artemis-jms-bridge/src/main/java/org/artemis/bridge/DestinationFactoryBean.java create mode 100644 examples/features/sub-modules/artemis-jms-bridge/artemis-jms-bridge/src/main/resources/bridge.xml create mode 100644 examples/features/sub-modules/artemis-jms-bridge/artemis-jms-bridge/src/main/webapp/WEB-INF/web.xml create mode 100644 examples/features/sub-modules/artemis-jms-bridge/pom.xml diff --git a/examples/features/sub-modules/artemis-jms-bridge/README.md b/examples/features/sub-modules/artemis-jms-bridge/README.md new file mode 100644 index 0000000000..9f60eb46ef --- /dev/null +++ b/examples/features/sub-modules/artemis-jms-bridge/README.md @@ -0,0 +1,93 @@ +# artemis-jms-bridge + +An example project showing how to do different varieties of bridging with ActiveMQ Brokers. + +## ActiveMQ to Artemis Camel Bridge + +This is an example of using Camel in the ActiveMQ broker to bridge messages between ActiveMQ and Artemis. + +### Prerequisites + +- install ActiveMQ +- install Artemis + +### Preparing + +From the root directory run `mvn clean package` + +Copy activemq-artemis-camel/target/activemq-artemis-camel-1.0.0-SNAPSHOT.war to the deploy dir of the ActiveMQ installation. + +Create an instance of the Artemis broker `$ARTEMIS_HOME/bin/artemis create --allow-anonymous --user admin --password password myBroker` + +Edit the $ARTEMIS_INSTANCE/etc/broker.xml and change the acceptor to listen to port 61617. Comment or remove all other acceptors. + +```xml + + tcp://0.0.0.0:61617?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE;useEpoll=true;amqpCredits=1000;amqpLowCredits=300 + +``` + +### Testing + +Start the Artemis broker. + +`$ARTEMIS_INSTANCE/bin/artemis run` + +Start the ActiveMQ broker. + +`$ACTIVEMQ_HOME/bin/standalone` + +Send some messages to the ActiveMQ broker. + +`./apache-activemq-5.11.0/bin/activemq producer --user admin --password password --destination queue://TEST.FOO` + +Log into the Artemis console and browse the messages in the TEST.FOO queue. + +## Artemis to ActiveMQ JMS Bridge + +This is an example of using the JMS bridge shipped with the Artemis broker to bridge to ActiveMQ. + +###Prerequisites + +- install ActiveMQ +- install Artemis + +###Preparing + +From the root dir run `mvn clean package`. + +Copy artemis-jms-bridge/target/artemis-jms-bridge-1.0.0-SNAPSHOT.war to the web directory of the Artemis installation. + +Create an instance of the Artemis broker `$ARTEMIS_HOME/bin/artemis create --allow-anonymous --user admin --password password myBroker` + +Edit the $ARTEMIS_INSTANCE/etc/broker.xml and change the acceptor to use invm. + +```xml + + tcp://0.0.0.0:61617?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE;useEpoll=true;amqpCredits=1000;amqpLowCredits=300 + vm://0 + +``` + +Edit the $ARTEMIS_INSTANCE/etc/bootstrap.xml and add the war file. + +```xml + +``` + +###Testing + + +Start the ActiveMQ broker. + +`$ACTIVEMQ_HOME/bin/standalone` + +Start the Artemis broker. + +`$ARTEMIS_INSTANCE/bin/artemis run` + +Send some messages to the queue TEST.BAR via the Artemis console. + +`$ARTEMIS_INSTANCE/bin/artemis producer --user admin --password password --destination queue://TEST.BAR --url tcp://localhost:61617 --message-count 1` + +Log into the ActiveMQ console and browse the messages in the TEST.BAR queue. diff --git a/examples/features/sub-modules/artemis-jms-bridge/activemq-artemis-camel/pom.xml b/examples/features/sub-modules/artemis-jms-bridge/activemq-artemis-camel/pom.xml new file mode 100644 index 0000000000..cfe72a7bea --- /dev/null +++ b/examples/features/sub-modules/artemis-jms-bridge/activemq-artemis-camel/pom.xml @@ -0,0 +1,101 @@ + + + + + 4.0.0 + + + org.apache.artemis.examples + artemis-jms-bridge-parent + 1.0.0-SNAPSHOT + + + activemq-artemis-camel + + war + + ActiveMQ to Artemis Camel Example + An example project showing how to do JMS bridging in ActiveMQ to Artemis using Apache Camel. + + + UTF-8 + UTF-8 + + 8 + 8 + + 3.1.0 + + 2.18.1 + 4.3.4.RELEASE + 1.1.0.Final + + + + + org.apache.activemq + activemq-client + 5.11.0 + + + org.apache.activemq + activemq-camel + 5.11.0 + + + org.apache.activemq + artemis-jms-client + 2.0.0 + + + org.apache.camel + camel-core + ${camel.version} + + + org.apache.camel + camel-spring + ${camel.version} + + + org.apache.camel + camel-jms + ${camel.version} + + + org.springframework + spring-web + ${spring.version} + + + org.jboss.slf4j + slf4j-jboss-logging + ${slf4j-jboss-logging.version} + + + + + + + org.apache.maven.plugins + maven-war-plugin + ${maven-war-plugin.version} + + + + + diff --git a/examples/features/sub-modules/artemis-jms-bridge/activemq-artemis-camel/src/main/resources/bridge.xml b/examples/features/sub-modules/artemis-jms-bridge/activemq-artemis-camel/src/main/resources/bridge.xml new file mode 100644 index 0000000000..23224b418f --- /dev/null +++ b/examples/features/sub-modules/artemis-jms-bridge/activemq-artemis-camel/src/main/resources/bridge.xml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/features/sub-modules/artemis-jms-bridge/activemq-artemis-camel/src/main/webapp/WEB-INF/web.xml b/examples/features/sub-modules/artemis-jms-bridge/activemq-artemis-camel/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..710cad2f45 --- /dev/null +++ b/examples/features/sub-modules/artemis-jms-bridge/activemq-artemis-camel/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,30 @@ + + + + + JMS Bridge Loader + + + contextConfigLocation + classpath:bridge.xml + + + org.springframework.web.context.ContextLoaderListener + + + \ No newline at end of file diff --git a/examples/features/sub-modules/artemis-jms-bridge/artemis-jms-bridge/pom.xml b/examples/features/sub-modules/artemis-jms-bridge/artemis-jms-bridge/pom.xml new file mode 100644 index 0000000000..3f34937ee3 --- /dev/null +++ b/examples/features/sub-modules/artemis-jms-bridge/artemis-jms-bridge/pom.xml @@ -0,0 +1,99 @@ + + + + + 4.0.0 + + + org.apache.artemis.examples + artemis-jms-bridge-parent + 1.0.0-SNAPSHOT + + + artemis-jms-bridge + + war + + Artemis JMS Bridge Example + An example project showing how to do JMS bridging in Artemis to an ActiveMQ. + + + UTF-8 + UTF-8 + + 8 + 8 + + 3.1.0 + + 2.18.1 + 4.3.4.RELEASE + 1.1.0.Final + + + + + org.apache.activemq + activemq-client + 5.11.0 + + + org.apache.activemq + activemq-camel + 5.11.0 + + + org.apache.activemq + artemis-jms-client + 2.0.0 + provided + + + org.apache.activemq + artemis-server + 2.0.0 + provided + + + org.apache.activemq + artemis-jms-server + 2.0.0 + provided + + + org.springframework + spring-web + ${spring.version} + + + org.jboss.slf4j + slf4j-jboss-logging + ${slf4j-jboss-logging.version} + + + + + + + org.apache.maven.plugins + maven-war-plugin + ${maven-war-plugin.version} + + + + + diff --git a/examples/features/sub-modules/artemis-jms-bridge/artemis-jms-bridge/src/main/java/org/artemis/bridge/ConnectionFactoryFactoryBean.java b/examples/features/sub-modules/artemis-jms-bridge/artemis-jms-bridge/src/main/java/org/artemis/bridge/ConnectionFactoryFactoryBean.java new file mode 100644 index 0000000000..5bf05eaca5 --- /dev/null +++ b/examples/features/sub-modules/artemis-jms-bridge/artemis-jms-bridge/src/main/java/org/artemis/bridge/ConnectionFactoryFactoryBean.java @@ -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. + */ +package org.artemis.bridge; + +import javax.jms.ConnectionFactory; + +/** + * @author Andy Taylor + */ +public class ConnectionFactoryFactoryBean implements org.apache.activemq.artemis.jms.bridge.ConnectionFactoryFactory { + + private final ConnectionFactory connectionFactory; + + public ConnectionFactoryFactoryBean(ConnectionFactory connectionFactory) { + this.connectionFactory = connectionFactory; + } + @java.lang.Override + public java.lang.Object createConnectionFactory() throws Exception { + return connectionFactory; + } +} diff --git a/examples/features/sub-modules/artemis-jms-bridge/artemis-jms-bridge/src/main/java/org/artemis/bridge/DestinationFactoryBean.java b/examples/features/sub-modules/artemis-jms-bridge/artemis-jms-bridge/src/main/java/org/artemis/bridge/DestinationFactoryBean.java new file mode 100644 index 0000000000..00b8b95b3c --- /dev/null +++ b/examples/features/sub-modules/artemis-jms-bridge/artemis-jms-bridge/src/main/java/org/artemis/bridge/DestinationFactoryBean.java @@ -0,0 +1,36 @@ +/** + * 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.artemis.bridge; + +import org.apache.activemq.artemis.jms.bridge.DestinationFactory; + +import javax.jms.Destination; + +/** + * @author Andy Taylor + */ +public class DestinationFactoryBean implements DestinationFactory { + private final Destination destination; + + public DestinationFactoryBean(Destination destination) { + this.destination = destination; + } + @Override + public Destination createDestination() throws Exception { + return destination; + } +} diff --git a/examples/features/sub-modules/artemis-jms-bridge/artemis-jms-bridge/src/main/resources/bridge.xml b/examples/features/sub-modules/artemis-jms-bridge/artemis-jms-bridge/src/main/resources/bridge.xml new file mode 100644 index 0000000000..ac76647f87 --- /dev/null +++ b/examples/features/sub-modules/artemis-jms-bridge/artemis-jms-bridge/src/main/resources/bridge.xml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/features/sub-modules/artemis-jms-bridge/artemis-jms-bridge/src/main/webapp/WEB-INF/web.xml b/examples/features/sub-modules/artemis-jms-bridge/artemis-jms-bridge/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..710cad2f45 --- /dev/null +++ b/examples/features/sub-modules/artemis-jms-bridge/artemis-jms-bridge/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,30 @@ + + + + + JMS Bridge Loader + + + contextConfigLocation + classpath:bridge.xml + + + org.springframework.web.context.ContextLoaderListener + + + \ No newline at end of file diff --git a/examples/features/sub-modules/artemis-jms-bridge/pom.xml b/examples/features/sub-modules/artemis-jms-bridge/pom.xml new file mode 100644 index 0000000000..2b46a9dcb4 --- /dev/null +++ b/examples/features/sub-modules/artemis-jms-bridge/pom.xml @@ -0,0 +1,64 @@ + + + + + 4.0.0 + + org.apache.artemis.examples + artemis-jms-bridge-parent + 1.0.0-SNAPSHOT + + pom + + Active Messaging Bridge Examples + An example project showing different ways to use bridges with ActiveMQ and Artemis. + + + UTF-8 + UTF-8 + + 8 + 8 + + 3.1.0 + + 2.18.1 + 4.3.4.RELEASE + 1.1.0.Final + + + + activemq-artemis-camel + artemis-jms-bridge + + + + + + true + never + + + false + + fuse-public-repository + FuseSource Community Release Repository + https://repo.fusesource.com/nexus/content/groups/public + + + + diff --git a/examples/features/sub-modules/pom.xml b/examples/features/sub-modules/pom.xml index d48371e3da..c49c758cc5 100644 --- a/examples/features/sub-modules/pom.xml +++ b/examples/features/sub-modules/pom.xml @@ -50,6 +50,7 @@ under the License. release artemis-ra-rar + artemis-jms-bridge