http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/interceptor-client-amqp/src/main/resources/activemq/server0/broker.xml ---------------------------------------------------------------------- diff --git a/examples/features/standard/interceptor-client-amqp/src/main/resources/activemq/server0/broker.xml b/examples/features/standard/interceptor-client-amqp/src/main/resources/activemq/server0/broker.xml deleted file mode 100644 index 6374087..0000000 --- a/examples/features/standard/interceptor-client-amqp/src/main/resources/activemq/server0/broker.xml +++ /dev/null @@ -1,176 +0,0 @@ -<?xml version='1.0'?> -<!-- -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. ---> - -<configuration xmlns="urn:activemq" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd"> - - <core xmlns="urn:activemq:core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="urn:activemq:core "> - - <name>0.0.0.0</name> - - <persistence-enabled>true</persistence-enabled> - - <!-- this could be ASYNCIO or NIO - --> - <journal-type>ASYNCIO</journal-type> - - <paging-directory>./data/paging</paging-directory> - - <remoting-incoming-interceptors> - <class-name>org.apache.activemq.artemis.amqp.example.SimpleAmqpInterceptor</class-name> - </remoting-incoming-interceptors> - - <bindings-directory>./data/bindings</bindings-directory> - - <journal-directory>./data/journal</journal-directory> - - <large-messages-directory>./data/large-messages</large-messages-directory> - - <journal-datasync>true</journal-datasync> - - <journal-min-files>2</journal-min-files> - - <journal-pool-files>-1</journal-pool-files> - - <!-- - You can verify the network health of a particular NIC by specifying the <network-check-NIC> element. - <network-check-NIC>theNicName</network-check-NIC> - --> - - <!-- - Use this to use an HTTP server to validate the network - <network-check-URL-list>http://www.apache.org</network-check-URL-list> --> - - <!-- <network-check-period>10000</network-check-period> --> - <!-- <network-check-timeout>1000</network-check-timeout> --> - - <!-- this is a comma separated list, no spaces, just DNS or IPs - it should accept IPV6 - - Warning: Make sure you understand your network topology as this is meant to validate if your network is valid. - Using IPs that could eventually disappear or be partially visible may defeat the purpose. - You can use a list of multiple IPs, and if any successful ping will make the server OK to continue running --> - <!-- <network-check-list>10.0.0.1</network-check-list> --> - - <!-- use this to customize the ping used for ipv4 addresses --> - <!-- <network-check-ping-command>ping -c 1 -t %d %s</network-check-ping-command> --> - - <!-- use this to customize the ping used for ipv6 addresses --> - <!-- <network-check-ping6-command>ping6 -c 1 %2$s</network-check-ping6-command> --> - - - - - <!-- how often we are looking for how many bytes are being used on the disk in ms --> - <disk-scan-period>5000</disk-scan-period> - - <!-- once the disk hits this limit the system will block, or close the connection in certain protocols - that won't support flow control. --> - <max-disk-usage>90</max-disk-usage> - - <!-- the system will enter into page mode once you hit this limit. - This is an estimate in bytes of how much the messages are using in memory --> - <global-max-size>100Mb</global-max-size> - - <acceptors> - <!-- Acceptor for every supported protocol --> - <acceptor name="artemis">tcp://0.0.0.0:61616?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE</acceptor> - - - <!-- AMQP Acceptor. Listens on default AMQP port for AMQP traffic.--> - <acceptor name="amqp">tcp://0.0.0.0:5672?protocols=AMQP</acceptor> - - <!-- STOMP Acceptor. --> - <acceptor name="stomp">tcp://0.0.0.0:61613?protocols=STOMP</acceptor> - - <!-- HornetQ Compatibility Acceptor. Enables HornetQ Core and STOMP for legacy HornetQ clients. --> - <acceptor name="hornetq">tcp://0.0.0.0:5445?protocols=HORNETQ,STOMP</acceptor> - - <!-- MQTT Acceptor --> - <acceptor name="mqtt">tcp://0.0.0.0:1883?protocols=MQTT</acceptor> - - </acceptors> - - - <security-settings> - <security-setting match="#"> - <permission type="createNonDurableQueue" roles="guest"/> - <permission type="deleteNonDurableQueue" roles="guest"/> - <permission type="createDurableQueue" roles="guest"/> - <permission type="deleteDurableQueue" roles="guest"/> - <permission type="createAddress" roles="guest"/> - <permission type="deleteAddress" roles="guest"/> - <permission type="consume" roles="guest"/> - <permission type="browse" roles="guest"/> - <permission type="send" roles="guest"/> - <!-- we need this otherwise ./artemis data imp wouldn't work --> - <permission type="manage" roles="guest"/> - </security-setting> - </security-settings> - - <address-settings> - <!-- if you define auto-create on certain queues, management has to be auto-create --> - <address-setting match="activemq.management#"> - <dead-letter-address>DLQ</dead-letter-address> - <expiry-address>ExpiryQueue</expiry-address> - <redelivery-delay>0</redelivery-delay> - <!-- with -1 only the global-max-size is in use for limiting --> - <max-size-bytes>-1</max-size-bytes> - <message-counter-history-day-limit>10</message-counter-history-day-limit> - <address-full-policy>PAGE</address-full-policy> - <auto-create-queues>true</auto-create-queues> - <auto-create-addresses>true</auto-create-addresses> - <auto-create-jms-queues>true</auto-create-jms-queues> - <auto-create-jms-topics>true</auto-create-jms-topics> - </address-setting> - <!--default for catch all--> - <address-setting match="#"> - <dead-letter-address>DLQ</dead-letter-address> - <expiry-address>ExpiryQueue</expiry-address> - <redelivery-delay>0</redelivery-delay> - <!-- with -1 only the global-max-size is in use for limiting --> - <max-size-bytes>-1</max-size-bytes> - <message-counter-history-day-limit>10</message-counter-history-day-limit> - <address-full-policy>PAGE</address-full-policy> - <auto-create-queues>true</auto-create-queues> - <auto-create-addresses>true</auto-create-addresses> - <auto-create-jms-queues>true</auto-create-jms-queues> - <auto-create-jms-topics>true</auto-create-jms-topics> - </address-setting> - </address-settings> - - <addresses> - <address name="DLQ"> - <anycast> - <queue name="DLQ" /> - </anycast> - </address> - <address name="ExpiryQueue"> - <anycast> - <queue name="ExpiryQueue" /> - </anycast> - </address> - - </addresses> - - </core> -</configuration>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/interceptor-client-mqtt/pom.xml ---------------------------------------------------------------------- diff --git a/examples/features/standard/interceptor-client-mqtt/pom.xml b/examples/features/standard/interceptor-client-mqtt/pom.xml deleted file mode 100644 index d9f97bf..0000000 --- a/examples/features/standard/interceptor-client-mqtt/pom.xml +++ /dev/null @@ -1,120 +0,0 @@ -<?xml version='1.0'?> -<!-- -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. ---> - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.activemq.examples.broker</groupId> - <artifactId>jms-examples</artifactId> - <version>2.5.0-SNAPSHOT</version> - </parent> - - <artifactId>interceptor-client-mqtt</artifactId> - <packaging>jar</packaging> - <name>ActiveMQ Artemis MQTT Interceptor Example</name> - - <properties> - <activemq.basedir>${project.basedir}/../../../..</activemq.basedir> - </properties> - - <dependencies> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-mqtt-protocol</artifactId> - <version>${project.version}</version> - </dependency> - - <dependency> - <groupId>org.fusesource.mqtt-client</groupId> - <artifactId>mqtt-client</artifactId> - </dependency> - - <dependency> - <groupId>io.netty</groupId> - <artifactId>netty-all</artifactId> - </dependency> - </dependencies> - - <build> - <plugins> - <plugin> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-maven-plugin</artifactId> - <executions> - <execution> - <id>create</id> - <goals> - <goal>create</goal> - </goals> - <configuration> - <libList><arg>org.apache.activemq.examples.broker:interceptor-client-mqtt:${project.version}</arg></libList> - <ignore>${noServer}</ignore> - <configuration>${basedir}/target/classes/activemq/server0</configuration> - </configuration> - </execution> - <execution> - <id>start</id> - <goals> - <goal>cli</goal> - </goals> - <configuration> - <ignore>${noServer}</ignore> - <spawn>true</spawn> - <testURI>tcp://localhost:61616</testURI> - <args> - <param>run</param> - </args> - </configuration> - </execution> - <execution> - <id>runClient</id> - <goals> - <goal>runClient</goal> - </goals> - <configuration> - <clientClass>org.apache.activemq.artemis.mqtt.example.InterceptorExample</clientClass> - </configuration> - </execution> - <execution> - <id>stop</id> - <goals> - <goal>cli</goal> - </goals> - <configuration> - <ignore>${noServer}</ignore> - <args> - <param>stop</param> - </args> - </configuration> - </execution> - </executions> - <dependencies> - <dependency> - <groupId>org.apache.activemq.examples.broker</groupId> - <artifactId>interceptor-client-mqtt</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> - </plugin> - </plugins> - </build> - -</project> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/interceptor-client-mqtt/readme.html ---------------------------------------------------------------------- diff --git a/examples/features/standard/interceptor-client-mqtt/readme.html b/examples/features/standard/interceptor-client-mqtt/readme.html deleted file mode 100644 index e8efad0..0000000 --- a/examples/features/standard/interceptor-client-mqtt/readme.html +++ /dev/null @@ -1,71 +0,0 @@ -<!-- -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. ---> - -<html> - <head> - <title>ActiveMQ Artemis JMS Interceptor Example</title> - <link rel="stylesheet" type="text/css" href="../../../common/common.css" /> - <link rel="stylesheet" type="text/css" href="../../../common/prettify.css" /> - <script type="text/javascript" src="../../../common/prettify.js"></script> - </head> - <body onload="prettyPrint()"> - <h1>MQTT Interceptor Example</h1> - - <pre>To run the example, simply type <b>mvn verify</b> from this directory, <br>or <b>mvn -PnoServer verify</b> if you want to start and create the server manually.</pre> - - - <p>This example shows you how to implement and configure a simple incoming, server-side MQTT interceptor with ActiveMQ Artemis.</p> - - <p>ActiveMQ Artemis allows an application to use an interceptor to hook into the messaging system. All that needs to do is to implement the - Interceptor interface, as defined below: </p> - <pre class="prettyprint"> - <code> - public interface Interceptor - { - boolean intercept(final MqttMessage mqttMessage, RemotingConnection connection); - } - </code> - </pre> - <p>Once you have your own interceptor class, add it to the broker.xml, as follows:</p> - <pre class="prettyprint"> - <code> - <configuration> - ... - <remoting-incoming-interceptors> - <class-name>org.apache.activemq.artemis.mqtt.example.SimpleMQTTInterceptor</class-name> - </remoting-incoming-interceptors> - ... - </configuration> - </code> - </pre> - - <p>With interceptor, you can handle various events in message processing. In this example, a simple interceptor, SimpleMQTTInterceptor, is implemented and configured. - When the example is running, the interceptor will modify the payload of a sample MQTT message.</p> - - <p>With our interceptor we always return <code>true</code> from the <code>intercept</code> method. If we were - to return <code>false</code> that signifies that no more interceptors are to run. - Throw an exception to abort processing of the packet.</p> - </body> -</html> - - - - - - http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/interceptor-client-mqtt/src/main/java/org/apache/activemq/artemis/mqtt/example/InterceptorExample.java ---------------------------------------------------------------------- diff --git a/examples/features/standard/interceptor-client-mqtt/src/main/java/org/apache/activemq/artemis/mqtt/example/InterceptorExample.java b/examples/features/standard/interceptor-client-mqtt/src/main/java/org/apache/activemq/artemis/mqtt/example/InterceptorExample.java deleted file mode 100644 index e72c93f..0000000 --- a/examples/features/standard/interceptor-client-mqtt/src/main/java/org/apache/activemq/artemis/mqtt/example/InterceptorExample.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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.apache.activemq.artemis.mqtt.example; - -import java.nio.charset.StandardCharsets; -import java.util.concurrent.TimeUnit; - -import org.fusesource.mqtt.client.BlockingConnection; -import org.fusesource.mqtt.client.MQTT; -import org.fusesource.mqtt.client.Message; -import org.fusesource.mqtt.client.QoS; -import org.fusesource.mqtt.client.Topic; - -/** - * A simple example that shows how to implement and use interceptors with ActiveMQ Artemis with the MQTT protocol. - */ -public class InterceptorExample { - public static void main(final String[] args) throws Exception { - - System.out.println("Connecting to Artemis using MQTT"); - MQTT mqtt = new MQTT(); - mqtt.setHost("tcp://localhost:1883"); - - BlockingConnection connection = mqtt.blockingConnection(); - connection.connect(); - - System.out.println("Connected to Artemis"); - - // Subscribe to a topic - Topic[] topics = {new Topic("mqtt/example/interceptor", QoS.EXACTLY_ONCE)}; - connection.subscribe(topics); - System.out.println("Subscribed to topics."); - - // Publish message - String payload1 = "This is message 1"; - - connection.publish("mqtt/example/interceptor", payload1.getBytes(), QoS.EXACTLY_ONCE, false); - - System.out.println("Sent message"); - - // Receive the sent message - Message message1 = connection.receive(5, TimeUnit.SECONDS); - - String messagePayload = new String(message1.getPayload(), StandardCharsets.UTF_8); - - System.out.println("Received message: " + messagePayload); - } -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/interceptor-client-mqtt/src/main/java/org/apache/activemq/artemis/mqtt/example/SimpleMQTTInterceptor.java ---------------------------------------------------------------------- diff --git a/examples/features/standard/interceptor-client-mqtt/src/main/java/org/apache/activemq/artemis/mqtt/example/SimpleMQTTInterceptor.java b/examples/features/standard/interceptor-client-mqtt/src/main/java/org/apache/activemq/artemis/mqtt/example/SimpleMQTTInterceptor.java deleted file mode 100644 index c705b81..0000000 --- a/examples/features/standard/interceptor-client-mqtt/src/main/java/org/apache/activemq/artemis/mqtt/example/SimpleMQTTInterceptor.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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.apache.activemq.artemis.mqtt.example; - -import java.nio.charset.Charset; - -import io.netty.handler.codec.mqtt.MqttPublishMessage; -import io.netty.handler.codec.mqtt.MqttConnectMessage; -import org.apache.activemq.artemis.core.protocol.mqtt.MQTTInterceptor; - - -import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection; - -import io.netty.handler.codec.mqtt.MqttMessage; - - -/** - * A simple Interceptor implementation - */ -public class SimpleMQTTInterceptor implements MQTTInterceptor { - - @Override - public boolean intercept(final MqttMessage mqttMessage, RemotingConnection connection) { - System.out.println("MQTT Interceptor gets called "); - - System.out.println("A MQTT control packet was intercepted " + mqttMessage.fixedHeader().messageType()); - - // If you need to handle an specific packet type: - if (mqttMessage instanceof MqttPublishMessage) { - MqttPublishMessage message = (MqttPublishMessage) mqttMessage; - - - String originalMessage = message.payload().toString(Charset.forName("UTF-8")); - System.out.println("Original message: " + originalMessage); - - // The new message content must not be bigger that the original content. - String modifiedMessage = "Modified message "; - - message.payload().setBytes(0, modifiedMessage.getBytes()); - } else { - if (mqttMessage instanceof MqttConnectMessage) { - MqttConnectMessage connectMessage = (MqttConnectMessage) mqttMessage; - System.out.println("A MQTT CONNECT control packet was intercepted " + connectMessage); - } - } - - - // We return true which means "call next interceptor" (if there is one) or target. - // If we returned false, it means "abort call" - no more interceptors would be called and neither would - // the target - return true; - } - -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/interceptor-client-mqtt/src/main/resources/activemq/server0/broker.xml ---------------------------------------------------------------------- diff --git a/examples/features/standard/interceptor-client-mqtt/src/main/resources/activemq/server0/broker.xml b/examples/features/standard/interceptor-client-mqtt/src/main/resources/activemq/server0/broker.xml deleted file mode 100644 index 82e55da..0000000 --- a/examples/features/standard/interceptor-client-mqtt/src/main/resources/activemq/server0/broker.xml +++ /dev/null @@ -1,180 +0,0 @@ -<?xml version='1.0'?> -<!-- -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. ---> - -<configuration xmlns="urn:activemq" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd"> - - <core xmlns="urn:activemq:core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="urn:activemq:core "> - - <name>0.0.0.0</name> - - <persistence-enabled>true</persistence-enabled> - - <!-- this could be ASYNCIO or NIO - --> - <journal-type>ASYNCIO</journal-type> - - <paging-directory>./data/paging</paging-directory> - - <remoting-incoming-interceptors> - <class-name>org.apache.activemq.artemis.mqtt.example.SimpleMQTTInterceptor</class-name> - </remoting-incoming-interceptors> - - <remoting-outgoing-interceptors> - <class-name>org.apache.activemq.artemis.mqtt.example.SimpleMQTTInterceptor</class-name> - </remoting-outgoing-interceptors> - - <bindings-directory>./data/bindings</bindings-directory> - - <journal-directory>./data/journal</journal-directory> - - <large-messages-directory>./data/large-messages</large-messages-directory> - - <journal-datasync>true</journal-datasync> - - <journal-min-files>2</journal-min-files> - - <journal-pool-files>-1</journal-pool-files> - - <!-- - You can verify the network health of a particular NIC by specifying the <network-check-NIC> element. - <network-check-NIC>theNicName</network-check-NIC> - --> - - <!-- - Use this to use an HTTP server to validate the network - <network-check-URL-list>http://www.apache.org</network-check-URL-list> --> - - <!-- <network-check-period>10000</network-check-period> --> - <!-- <network-check-timeout>1000</network-check-timeout> --> - - <!-- this is a comma separated list, no spaces, just DNS or IPs - it should accept IPV6 - - Warning: Make sure you understand your network topology as this is meant to validate if your network is valid. - Using IPs that could eventually disappear or be partially visible may defeat the purpose. - You can use a list of multiple IPs, and if any successful ping will make the server OK to continue running --> - <!-- <network-check-list>10.0.0.1</network-check-list> --> - - <!-- use this to customize the ping used for ipv4 addresses --> - <!-- <network-check-ping-command>ping -c 1 -t %d %s</network-check-ping-command> --> - - <!-- use this to customize the ping used for ipv6 addresses --> - <!-- <network-check-ping6-command>ping6 -c 1 %2$s</network-check-ping6-command> --> - - - - - <!-- how often we are looking for how many bytes are being used on the disk in ms --> - <disk-scan-period>5000</disk-scan-period> - - <!-- once the disk hits this limit the system will block, or close the connection in certain protocols - that won't support flow control. --> - <max-disk-usage>90</max-disk-usage> - - <!-- the system will enter into page mode once you hit this limit. - This is an estimate in bytes of how much the messages are using in memory --> - <global-max-size>100Mb</global-max-size> - - <acceptors> - <!-- Acceptor for every supported protocol --> - <acceptor name="artemis">tcp://0.0.0.0:61616?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE</acceptor> - - - <!-- AMQP Acceptor. Listens on default AMQP port for AMQP traffic.--> - <acceptor name="amqp">tcp://0.0.0.0:5672?protocols=AMQP</acceptor> - - <!-- STOMP Acceptor. --> - <acceptor name="stomp">tcp://0.0.0.0:61613?protocols=STOMP</acceptor> - - <!-- HornetQ Compatibility Acceptor. Enables HornetQ Core and STOMP for legacy HornetQ clients. --> - <acceptor name="hornetq">tcp://0.0.0.0:5445?protocols=HORNETQ,STOMP</acceptor> - - <!-- MQTT Acceptor --> - <acceptor name="mqtt">tcp://0.0.0.0:1883?protocols=MQTT</acceptor> - - </acceptors> - - - <security-settings> - <security-setting match="#"> - <permission type="createNonDurableQueue" roles="guest"/> - <permission type="deleteNonDurableQueue" roles="guest"/> - <permission type="createDurableQueue" roles="guest"/> - <permission type="deleteDurableQueue" roles="guest"/> - <permission type="createAddress" roles="guest"/> - <permission type="deleteAddress" roles="guest"/> - <permission type="consume" roles="guest"/> - <permission type="browse" roles="guest"/> - <permission type="send" roles="guest"/> - <!-- we need this otherwise ./artemis data imp wouldn't work --> - <permission type="manage" roles="guest"/> - </security-setting> - </security-settings> - - <address-settings> - <!-- if you define auto-create on certain queues, management has to be auto-create --> - <address-setting match="activemq.management#"> - <dead-letter-address>DLQ</dead-letter-address> - <expiry-address>ExpiryQueue</expiry-address> - <redelivery-delay>0</redelivery-delay> - <!-- with -1 only the global-max-size is in use for limiting --> - <max-size-bytes>-1</max-size-bytes> - <message-counter-history-day-limit>10</message-counter-history-day-limit> - <address-full-policy>PAGE</address-full-policy> - <auto-create-queues>true</auto-create-queues> - <auto-create-addresses>true</auto-create-addresses> - <auto-create-jms-queues>true</auto-create-jms-queues> - <auto-create-jms-topics>true</auto-create-jms-topics> - </address-setting> - <!--default for catch all--> - <address-setting match="#"> - <dead-letter-address>DLQ</dead-letter-address> - <expiry-address>ExpiryQueue</expiry-address> - <redelivery-delay>0</redelivery-delay> - <!-- with -1 only the global-max-size is in use for limiting --> - <max-size-bytes>-1</max-size-bytes> - <message-counter-history-day-limit>10</message-counter-history-day-limit> - <address-full-policy>PAGE</address-full-policy> - <auto-create-queues>true</auto-create-queues> - <auto-create-addresses>true</auto-create-addresses> - <auto-create-jms-queues>true</auto-create-jms-queues> - <auto-create-jms-topics>true</auto-create-jms-topics> - </address-setting> - </address-settings> - - <addresses> - <address name="DLQ"> - <anycast> - <queue name="DLQ" /> - </anycast> - </address> - <address name="ExpiryQueue"> - <anycast> - <queue name="ExpiryQueue" /> - </anycast> - </address> - - </addresses> - - </core> -</configuration> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/interceptor-client/pom.xml ---------------------------------------------------------------------- diff --git a/examples/features/standard/interceptor-client/pom.xml b/examples/features/standard/interceptor-client/pom.xml index 3d52359..5d233f0 100644 --- a/examples/features/standard/interceptor-client/pom.xml +++ b/examples/features/standard/interceptor-client/pom.xml @@ -29,7 +29,7 @@ under the License. <artifactId>interceptor-client</artifactId> <packaging>jar</packaging> - <name>ActiveMQ Artemis JMS Interceptor Example</name> + <name>ActiveMQ Artemis JMS Interceptor Client Example</name> <properties> <activemq.basedir>${project.basedir}/../../../..</activemq.basedir> @@ -104,7 +104,23 @@ under the License. </dependency> </dependencies> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-clean-plugin</artifactId> + </plugin> </plugins> </build> - -</project> + <profiles> + <profile> + <id>release</id> + <build> + <plugins> + <plugin> + <groupId>com.vladsch.flexmark</groupId> + <artifactId>markdown-page-generator-plugin</artifactId> + </plugin> + </plugins> + </build> + </profile> + </profiles> +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/interceptor-client/readme.html ---------------------------------------------------------------------- diff --git a/examples/features/standard/interceptor-client/readme.html b/examples/features/standard/interceptor-client/readme.html deleted file mode 100644 index 42b1e18..0000000 --- a/examples/features/standard/interceptor-client/readme.html +++ /dev/null @@ -1,72 +0,0 @@ -<!-- -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. ---> - -<html> - <head> - <title>ActiveMQ Artemis JMS Interceptor Example</title> - <link rel="stylesheet" type="text/css" href="../../../common/common.css" /> - <link rel="stylesheet" type="text/css" href="../../../common/prettify.css" /> - <script type="text/javascript" src="../../../common/prettify.js"></script> - </head> - <body onload="prettyPrint()"> - <h1>JMS Interceptor Example</h1> - - <pre>To run the example, simply type <b>mvn verify</b> from this directory, <br>or <b>mvn -PnoServer verify</b> if you want to start and create the server manually.</pre> - - - <p>This example shows you how to implement and configure a simple incoming, server-side interceptor with ActiveMQ Artemis.</p> - - <p>ActiveMQ Artemis allows an application to use an interceptor to hook into the messaging system. All that needs to do is to implement the - Interceptor interface, as defined below: </p> - <pre class="prettyprint"> - <code> - public interface Interceptor - { - boolean intercept(Packet packet, RemotingConnection connection) throws ActiveMQException; - } - </code> - </pre> - <p>Once you have your own interceptor class, add it to the broker.xml, as follows:</p> - <pre class="prettyprint"> - <code> - <configuration> - ... - <remoting-incoming-interceptors> - <class-name>org.apache.activemq.artemis.jms.example.SimpleInterceptor</class-name> - </remoting-incoming-interceptors> - ... - </configuration> - </code> - </pre> - - <p>With interceptor, you can handle various events in message processing. In this example, a simple interceptor, SimpleInterceptor, is implemented and configured. - When the example is running, the interceptor will print out each events that are passed in the interceptor. And it will add a string property to the message being - delivered. You can see that after the message is received, there will be a new string property appears in the received message.</p> - - <p>With our interceptor we always return <code>true</code> from the <code>intercept</code> method. If we were - to return <code>false</code> that signifies that no more interceptors are to run or the target - is not to be called. Return <code>false</code> to abort processing of the packet.</p> - </body> -</html> - - - - - - http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/interceptor-client/readme.md ---------------------------------------------------------------------- diff --git a/examples/features/standard/interceptor-client/readme.md b/examples/features/standard/interceptor-client/readme.md new file mode 100644 index 0000000..2f83bce --- /dev/null +++ b/examples/features/standard/interceptor-client/readme.md @@ -0,0 +1,13 @@ +# JMS Interceptor Client Example + +To run the example, simply type **mvn verify** from this directory, or **mvn -PnoServer verify** if you want to start and create the broker manually. + +This example shows you how to implement and configure a simple incoming, client-side interceptor with ActiveMQ Artemis. + +ActiveMQ Artemis allows an application to use an interceptor to hook into the messaging system. To intercept "core" packets all that needs to be done is to implement the `org.apache.activemq.artemis.api.core.Interceptor` interface. + +Once you have your own interceptor class, add it to client via the `incomingInterceptorList` URL parameter. + +With interceptors, you can handle various events in message processing. In this example, a simple interceptor, SimpleInterceptor, is implemented and configured. When the example is running the interceptor will print out each events that are passed in the interceptor. And it will add a string property to the message being delivered. You can see that after the message is received, there will be a new string property appears in the received message. + +With our interceptor we always return `true` from the `intercept` method. If we were to return `false` that signifies that no more interceptors are to run or the target is not to be called. Return `false` to abort processing of the packet. http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/interceptor-client/src/main/java/org/apache/activemq/artemis/jms/example/InterceptorExample.java ---------------------------------------------------------------------- diff --git a/examples/features/standard/interceptor-client/src/main/java/org/apache/activemq/artemis/jms/example/InterceptorExample.java b/examples/features/standard/interceptor-client/src/main/java/org/apache/activemq/artemis/jms/example/InterceptorExample.java index 1f70c54..a84d9df 100644 --- a/examples/features/standard/interceptor-client/src/main/java/org/apache/activemq/artemis/jms/example/InterceptorExample.java +++ b/examples/features/standard/interceptor-client/src/main/java/org/apache/activemq/artemis/jms/example/InterceptorExample.java @@ -27,7 +27,7 @@ import javax.jms.TextMessage; import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; /** - * A simple JMS example that shows how to implement and use interceptors with ActiveMQ Artemis. + * A simple JMS example that shows how to implement and use client-side interceptors with ActiveMQ Artemis. */ public class InterceptorExample { http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/interceptor-mqtt/pom.xml ---------------------------------------------------------------------- diff --git a/examples/features/standard/interceptor-mqtt/pom.xml b/examples/features/standard/interceptor-mqtt/pom.xml new file mode 100644 index 0000000..20053d4 --- /dev/null +++ b/examples/features/standard/interceptor-mqtt/pom.xml @@ -0,0 +1,136 @@ +<?xml version='1.0'?> +<!-- +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. +--> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.activemq.examples.broker</groupId> + <artifactId>jms-examples</artifactId> + <version>2.5.0-SNAPSHOT</version> + </parent> + + <artifactId>interceptor-mqtt</artifactId> + <packaging>jar</packaging> + <name>ActiveMQ Artemis MQTT Interceptor Example</name> + + <properties> + <activemq.basedir>${project.basedir}/../../../..</activemq.basedir> + </properties> + + <dependencies> + <dependency> + <groupId>org.apache.activemq</groupId> + <artifactId>artemis-mqtt-protocol</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>org.fusesource.mqtt-client</groupId> + <artifactId>mqtt-client</artifactId> + </dependency> + + <dependency> + <groupId>io.netty</groupId> + <artifactId>netty-all</artifactId> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.activemq</groupId> + <artifactId>artemis-maven-plugin</artifactId> + <executions> + <execution> + <id>create</id> + <goals> + <goal>create</goal> + </goals> + <configuration> + <libList><arg>org.apache.activemq.examples.broker:interceptor-client-mqtt:${project.version}</arg></libList> + <ignore>${noServer}</ignore> + <configuration>${basedir}/target/classes/activemq/server0</configuration> + </configuration> + </execution> + <execution> + <id>start</id> + <goals> + <goal>cli</goal> + </goals> + <configuration> + <ignore>${noServer}</ignore> + <spawn>true</spawn> + <testURI>tcp://localhost:1883</testURI> + <args> + <param>run</param> + </args> + </configuration> + </execution> + <execution> + <id>runClient</id> + <goals> + <goal>runClient</goal> + </goals> + <configuration> + <clientClass>org.apache.activemq.artemis.mqtt.example.InterceptorExample</clientClass> + </configuration> + </execution> + <execution> + <id>stop</id> + <goals> + <goal>cli</goal> + </goals> + <configuration> + <ignore>${noServer}</ignore> + <args> + <param>stop</param> + </args> + </configuration> + </execution> + </executions> + <dependencies> + <dependency> + <groupId>org.apache.activemq.examples.broker</groupId> + <artifactId>interceptor-client-mqtt</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-clean-plugin</artifactId> + </plugin> + </plugins> + </build> + <profiles> + <profile> + <id>release</id> + <build> + <plugins> + <plugin> + <groupId>com.vladsch.flexmark</groupId> + <artifactId>markdown-page-generator-plugin</artifactId> + </plugin> + </plugins> + </build> + </profile> + </profiles> +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/interceptor-mqtt/readme.md ---------------------------------------------------------------------- diff --git a/examples/features/standard/interceptor-mqtt/readme.md b/examples/features/standard/interceptor-mqtt/readme.md new file mode 100644 index 0000000..da62c76 --- /dev/null +++ b/examples/features/standard/interceptor-mqtt/readme.md @@ -0,0 +1,21 @@ +# MQTT Interceptor Example + +To run the example, simply type **mvn verify** from this directory, or **mvn -PnoServer verify** if you want to start and create the broker manually. + +This example shows you how to implement and configure a simple incoming, server-side MQTT interceptor with ActiveMQ Artemis. + +ActiveMQ Artemis allows an application to use an interceptor to hook into the messaging system. To intercept MQTT packets all that needs to be done is to implement the `org.apache.activemq.artemis.core.protocol.mqtt.MQTTInterceptor` interface. + +Once you have your own interceptor class add it to the broker.xml as follows: + + <configuration> + ... + <remoting-incoming-interceptors> + <class-name>org.apache.activemq.artemis.mqtt.example.SimpleMQTTInterceptor</class-name> + </remoting-incoming-interceptors> + ... + </configuration> + +With an interceptor you can handle various events in message processing. In this example, a simple interceptor, SimpleMQTTInterceptor, is implemented and configured. When the example is running, the interceptor will modify the payload of a sample MQTT message. + +With our interceptor we always return `true` from the `intercept` method. If we were to return `false` that signifies that no more interceptors are to run. Throw an exception to abort processing of the packet. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/interceptor-mqtt/src/main/java/org/apache/activemq/artemis/mqtt/example/InterceptorExample.java ---------------------------------------------------------------------- diff --git a/examples/features/standard/interceptor-mqtt/src/main/java/org/apache/activemq/artemis/mqtt/example/InterceptorExample.java b/examples/features/standard/interceptor-mqtt/src/main/java/org/apache/activemq/artemis/mqtt/example/InterceptorExample.java new file mode 100644 index 0000000..e72c93f --- /dev/null +++ b/examples/features/standard/interceptor-mqtt/src/main/java/org/apache/activemq/artemis/mqtt/example/InterceptorExample.java @@ -0,0 +1,62 @@ +/* + * 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.apache.activemq.artemis.mqtt.example; + +import java.nio.charset.StandardCharsets; +import java.util.concurrent.TimeUnit; + +import org.fusesource.mqtt.client.BlockingConnection; +import org.fusesource.mqtt.client.MQTT; +import org.fusesource.mqtt.client.Message; +import org.fusesource.mqtt.client.QoS; +import org.fusesource.mqtt.client.Topic; + +/** + * A simple example that shows how to implement and use interceptors with ActiveMQ Artemis with the MQTT protocol. + */ +public class InterceptorExample { + public static void main(final String[] args) throws Exception { + + System.out.println("Connecting to Artemis using MQTT"); + MQTT mqtt = new MQTT(); + mqtt.setHost("tcp://localhost:1883"); + + BlockingConnection connection = mqtt.blockingConnection(); + connection.connect(); + + System.out.println("Connected to Artemis"); + + // Subscribe to a topic + Topic[] topics = {new Topic("mqtt/example/interceptor", QoS.EXACTLY_ONCE)}; + connection.subscribe(topics); + System.out.println("Subscribed to topics."); + + // Publish message + String payload1 = "This is message 1"; + + connection.publish("mqtt/example/interceptor", payload1.getBytes(), QoS.EXACTLY_ONCE, false); + + System.out.println("Sent message"); + + // Receive the sent message + Message message1 = connection.receive(5, TimeUnit.SECONDS); + + String messagePayload = new String(message1.getPayload(), StandardCharsets.UTF_8); + + System.out.println("Received message: " + messagePayload); + } +} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/interceptor-mqtt/src/main/java/org/apache/activemq/artemis/mqtt/example/SimpleMQTTInterceptor.java ---------------------------------------------------------------------- diff --git a/examples/features/standard/interceptor-mqtt/src/main/java/org/apache/activemq/artemis/mqtt/example/SimpleMQTTInterceptor.java b/examples/features/standard/interceptor-mqtt/src/main/java/org/apache/activemq/artemis/mqtt/example/SimpleMQTTInterceptor.java new file mode 100644 index 0000000..5297e61 --- /dev/null +++ b/examples/features/standard/interceptor-mqtt/src/main/java/org/apache/activemq/artemis/mqtt/example/SimpleMQTTInterceptor.java @@ -0,0 +1,63 @@ +/* + * 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.apache.activemq.artemis.mqtt.example; + +import java.nio.charset.Charset; + +import io.netty.handler.codec.mqtt.MqttConnectMessage; +import io.netty.handler.codec.mqtt.MqttMessage; +import io.netty.handler.codec.mqtt.MqttPublishMessage; +import org.apache.activemq.artemis.core.protocol.mqtt.MQTTInterceptor; +import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection; + + +/** + * A simple Interceptor implementation + */ +public class SimpleMQTTInterceptor implements MQTTInterceptor { + + @Override + public boolean intercept(final MqttMessage mqttMessage, RemotingConnection connection) { + System.out.println("MQTT control packet was intercepted " + mqttMessage.fixedHeader().messageType()); + + // If you need to handle an specific packet type: + if (mqttMessage instanceof MqttPublishMessage) { + MqttPublishMessage message = (MqttPublishMessage) mqttMessage; + + + String originalMessage = message.payload().toString(Charset.forName("UTF-8")); + System.out.println("Original message: " + originalMessage); + + // The new message content must not be bigger that the original content. + String modifiedMessage = "Modified message "; + + message.payload().setBytes(0, modifiedMessage.getBytes()); + } else { + if (mqttMessage instanceof MqttConnectMessage) { + MqttConnectMessage connectMessage = (MqttConnectMessage) mqttMessage; + System.out.println("MQTT CONNECT control packet was intercepted " + connectMessage); + } + } + + + // We return true which means "call next interceptor" (if there is one) or target. + // If we returned false, it means "abort call" - no more interceptors would be called and neither would + // the target + return true; + } + +} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/interceptor-mqtt/src/main/resources/activemq/server0/broker.xml ---------------------------------------------------------------------- diff --git a/examples/features/standard/interceptor-mqtt/src/main/resources/activemq/server0/broker.xml b/examples/features/standard/interceptor-mqtt/src/main/resources/activemq/server0/broker.xml new file mode 100644 index 0000000..e04d65a --- /dev/null +++ b/examples/features/standard/interceptor-mqtt/src/main/resources/activemq/server0/broker.xml @@ -0,0 +1,56 @@ +<?xml version='1.0'?> +<!-- +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. +--> +<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd"> + <core xmlns="urn:activemq:core"> + + <bindings-directory>./data/bindings</bindings-directory> + + <journal-directory>./data/journal</journal-directory> + + <large-messages-directory>./data/largemessages</large-messages-directory> + + <paging-directory>./data/paging</paging-directory> + + <remoting-incoming-interceptors> + <class-name>org.apache.activemq.artemis.mqtt.example.SimpleMQTTInterceptor</class-name> + </remoting-incoming-interceptors> + + <remoting-outgoing-interceptors> + <class-name>org.apache.activemq.artemis.mqtt.example.SimpleMQTTInterceptor</class-name> + </remoting-outgoing-interceptors> + + <acceptors> + <acceptor name="mqtt">tcp://0.0.0.0:1883?protocols=CORE,MQTT</acceptor> + </acceptors> + + <security-settings> + <security-setting match="#"> + <permission type="createNonDurableQueue" roles="guest"/> + <permission type="deleteNonDurableQueue" roles="guest"/> + <permission type="createDurableQueue" roles="guest"/> + <permission type="deleteDurableQueue" roles="guest"/> + <permission type="createAddress" roles="guest"/> + <permission type="deleteAddress" roles="guest"/> + <permission type="consume" roles="guest"/> + <permission type="send" roles="guest"/> + </security-setting> + </security-settings> + </core> +</configuration> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/interceptor/pom.xml ---------------------------------------------------------------------- diff --git a/examples/features/standard/interceptor/pom.xml b/examples/features/standard/interceptor/pom.xml index 2101ae6..310b20c 100644 --- a/examples/features/standard/interceptor/pom.xml +++ b/examples/features/standard/interceptor/pom.xml @@ -104,7 +104,23 @@ under the License. </dependency> </dependencies> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-clean-plugin</artifactId> + </plugin> </plugins> </build> - -</project> + <profiles> + <profile> + <id>release</id> + <build> + <plugins> + <plugin> + <groupId>com.vladsch.flexmark</groupId> + <artifactId>markdown-page-generator-plugin</artifactId> + </plugin> + </plugins> + </build> + </profile> + </profiles> +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/interceptor/readme.html ---------------------------------------------------------------------- diff --git a/examples/features/standard/interceptor/readme.html b/examples/features/standard/interceptor/readme.html deleted file mode 100644 index 42b1e18..0000000 --- a/examples/features/standard/interceptor/readme.html +++ /dev/null @@ -1,72 +0,0 @@ -<!-- -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. ---> - -<html> - <head> - <title>ActiveMQ Artemis JMS Interceptor Example</title> - <link rel="stylesheet" type="text/css" href="../../../common/common.css" /> - <link rel="stylesheet" type="text/css" href="../../../common/prettify.css" /> - <script type="text/javascript" src="../../../common/prettify.js"></script> - </head> - <body onload="prettyPrint()"> - <h1>JMS Interceptor Example</h1> - - <pre>To run the example, simply type <b>mvn verify</b> from this directory, <br>or <b>mvn -PnoServer verify</b> if you want to start and create the server manually.</pre> - - - <p>This example shows you how to implement and configure a simple incoming, server-side interceptor with ActiveMQ Artemis.</p> - - <p>ActiveMQ Artemis allows an application to use an interceptor to hook into the messaging system. All that needs to do is to implement the - Interceptor interface, as defined below: </p> - <pre class="prettyprint"> - <code> - public interface Interceptor - { - boolean intercept(Packet packet, RemotingConnection connection) throws ActiveMQException; - } - </code> - </pre> - <p>Once you have your own interceptor class, add it to the broker.xml, as follows:</p> - <pre class="prettyprint"> - <code> - <configuration> - ... - <remoting-incoming-interceptors> - <class-name>org.apache.activemq.artemis.jms.example.SimpleInterceptor</class-name> - </remoting-incoming-interceptors> - ... - </configuration> - </code> - </pre> - - <p>With interceptor, you can handle various events in message processing. In this example, a simple interceptor, SimpleInterceptor, is implemented and configured. - When the example is running, the interceptor will print out each events that are passed in the interceptor. And it will add a string property to the message being - delivered. You can see that after the message is received, there will be a new string property appears in the received message.</p> - - <p>With our interceptor we always return <code>true</code> from the <code>intercept</code> method. If we were - to return <code>false</code> that signifies that no more interceptors are to run or the target - is not to be called. Return <code>false</code> to abort processing of the packet.</p> - </body> -</html> - - - - - - http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/interceptor/readme.md ---------------------------------------------------------------------- diff --git a/examples/features/standard/interceptor/readme.md b/examples/features/standard/interceptor/readme.md new file mode 100644 index 0000000..13f2726 --- /dev/null +++ b/examples/features/standard/interceptor/readme.md @@ -0,0 +1,21 @@ +# JMS Interceptor Example + +To run the example, simply type **mvn verify** from this directory, or **mvn -PnoServer verify** if you want to start and create the broker manually. + +This example shows you how to implement and configure a simple incoming, server-side interceptor with ActiveMQ Artemis. + +ActiveMQ Artemis allows an application to use an interceptor to hook into the messaging system. To intercept "core" packets all that needs to be done is to implement the `org.apache.activemq.artemis.api.core.Interceptor` interface. + +Once you have your own interceptor class, add it to the broker.xml, as follows: + + <configuration> + ... + <remoting-incoming-interceptors> + <class-name>org.apache.activemq.artemis.jms.example.SimpleInterceptor</class-name> + </remoting-incoming-interceptors> + ... + </configuration> + +With interceptors, you can handle various events in message processing. In this example, a simple interceptor, SimpleInterceptor, is implemented and configured. When the example is running the interceptor will print out each events that are passed in the interceptor. And it will add a string property to the message being delivered. You can see that after the message is received, there will be a new string property appears in the received message. + +With our interceptor we always return `true` from the `intercept` method. If we were to return `false` that signifies that no more interceptors are to run or the target is not to be called. Return `false` to abort processing of the packet. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/interceptor/src/main/resources/activemq/server0/broker.xml ---------------------------------------------------------------------- diff --git a/examples/features/standard/interceptor/src/main/resources/activemq/server0/broker.xml b/examples/features/standard/interceptor/src/main/resources/activemq/server0/broker.xml index 11c324d..01a70c3 100644 --- a/examples/features/standard/interceptor/src/main/resources/activemq/server0/broker.xml +++ b/examples/features/standard/interceptor/src/main/resources/activemq/server0/broker.xml @@ -16,10 +16,8 @@ software distributed under the License is distributed on an KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ---><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> - - - +--> +<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd"> <core xmlns="urn:activemq:core"> <bindings-directory>./data/bindings</bindings-directory> @@ -30,7 +28,6 @@ under the License. <paging-directory>./data/paging</paging-directory> - <remoting-incoming-interceptors> <class-name>org.apache.activemq.artemis.jms.example.SimpleInterceptor</class-name> </remoting-incoming-interceptors> @@ -54,7 +51,7 @@ under the License. </security-setting> </security-settings> - <addresses> + <addresses> <address name="exampleQueue"> <anycast> <queue name="exampleQueue"/> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/jms-auto-closeable/pom.xml ---------------------------------------------------------------------- diff --git a/examples/features/standard/jms-auto-closeable/pom.xml b/examples/features/standard/jms-auto-closeable/pom.xml index 60bc37e..3ea9816 100644 --- a/examples/features/standard/jms-auto-closeable/pom.xml +++ b/examples/features/standard/jms-auto-closeable/pom.xml @@ -99,7 +99,23 @@ under the License. </dependency> </dependencies> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-clean-plugin</artifactId> + </plugin> </plugins> </build> - -</project> + <profiles> + <profile> + <id>release</id> + <build> + <plugins> + <plugin> + <groupId>com.vladsch.flexmark</groupId> + <artifactId>markdown-page-generator-plugin</artifactId> + </plugin> + </plugins> + </build> + </profile> + </profiles> +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/jms-auto-closeable/readme.html ---------------------------------------------------------------------- diff --git a/examples/features/standard/jms-auto-closeable/readme.html b/examples/features/standard/jms-auto-closeable/readme.html deleted file mode 100644 index 80dc410..0000000 --- a/examples/features/standard/jms-auto-closeable/readme.html +++ /dev/null @@ -1,96 +0,0 @@ -<!-- -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. ---> - -<html> - <head> - <title>ActiveMQ Artemis JMS Auto Closable Example</title> - <link rel="stylesheet" type="text/css" href="../../../common/common.css" /> - <link rel="stylesheet" type="text/css" href="../../../common/prettify.css" /> - <script type="text/javascript" src="../../../common/prettify.js"></script> - </head> - <body onload="prettyPrint()"> - <h1>JMS Auto Closable Example</h1> - - <pre>To run the example, simply type <b>mvn verify</b> from this directory, <br>or <b>mvn -PnoServer verify</b> if you want to start and create the server manually.</pre> - - <p>This example shows you how JMS resources, such as connections, sessions and consumers, in JMS 2 can be automatically closed on error.</p> - <p>In this instance we auto close a connection after a subsequent call to a JMS producer send fails</p> - - <h2>Example step-by-step</h2> - - <ol> - <li>First we need to get an initial context so we can look-up the JMS connection factory and destination objects from JNDI. This initial context will get it's properties from the <code>client-jndi.properties</code> file in the directory <code>../common/config</code></li> - <pre class="prettyprint"> - <code>InitialContext initialContext = getContext();</code> - </pre> - - <li>We look-up the JMS queue object from JNDI</li> - <pre class="prettyprint"> - <code>Queue queue = (Queue) initialContext.lookup("/queue/exampleQueue");</code> - </pre> - - <li>We look-up the JMS connection factory object from JNDI</li> - <pre class="prettyprint"> - <code>ConnectionFactory cf = (ConnectionFactory) initialContext.lookup("/ConnectionFactory");</code> - </pre> - - <li>We create a JMS context but we do it inside the try-with-resources statement like so:</li> - <pre class="prettyprint"> - <code> - try - ( - JMSContext jmsContext = cf.createContext() - ) - </code> - </pre> - - <li>Inside the following try block we first create the producer</li> - <pre class="prettyprint"> - <code>JMSProducer jmsProducer = jmsContext.createProducer();</code> - </pre> - - <li>We then try to send a message. It is this call that throws an exception as the producer doesn't have the privileges - to send a message</li> - <pre class="prettyprint"> - <code>jmsProducer.send(queue, "this message will fail security!");</code> - </pre> - - <li>We catch the exception from the send message and can do what we want, however the JMSContext will have been closed - prior to entering the catch block.</li> - <pre class="prettyprint"> - <code>System.out.println("expected exception from jmsProducer.send: " + e.getMessage());</code> - </pre> - - <li>And finally, we close the Initial Context, note we no longer have to worry about clearing up the JMSContext.</li> - - <pre class="prettyprint"> - <code>finally - { - if (initialContext != null) - { - initialContext.close(); - } - }</code> - </pre> - - - - </ol> - </body> -</html> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/jms-auto-closeable/readme.md ---------------------------------------------------------------------- diff --git a/examples/features/standard/jms-auto-closeable/readme.md b/examples/features/standard/jms-auto-closeable/readme.md new file mode 100644 index 0000000..248fca1 --- /dev/null +++ b/examples/features/standard/jms-auto-closeable/readme.md @@ -0,0 +1,7 @@ +# JMS Auto Closable Example + +To run the example, simply type **mvn verify** from this directory, or **mvn -PnoServer verify** if you want to start and create the broker manually. + +This example shows you how JMS resources such as connections, sessions and consumers in JMS 2 can be automatically closed on error. + +In this instance we auto close a connection after a subsequent call to a JMS producer send fails. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/jms-bridge/pom.xml ---------------------------------------------------------------------- diff --git a/examples/features/standard/jms-bridge/pom.xml b/examples/features/standard/jms-bridge/pom.xml index 320bcad..4422130 100644 --- a/examples/features/standard/jms-bridge/pom.xml +++ b/examples/features/standard/jms-bridge/pom.xml @@ -152,7 +152,23 @@ under the License. </dependency> </dependencies> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-clean-plugin</artifactId> + </plugin> </plugins> </build> - -</project> + <profiles> + <profile> + <id>release</id> + <build> + <plugins> + <plugin> + <groupId>com.vladsch.flexmark</groupId> + <artifactId>markdown-page-generator-plugin</artifactId> + </plugin> + </plugins> + </build> + </profile> + </profiles> +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/jms-bridge/readme.html ---------------------------------------------------------------------- diff --git a/examples/features/standard/jms-bridge/readme.html b/examples/features/standard/jms-bridge/readme.html deleted file mode 100644 index 182f7fa..0000000 --- a/examples/features/standard/jms-bridge/readme.html +++ /dev/null @@ -1,246 +0,0 @@ -<!-- -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. ---> - -<html> - <head> - <title>ActiveMQ Artemis JMS Bridge Example</title> - <link rel="stylesheet" type="text/css" href="../../../common/common.css" /> - <link rel="stylesheet" type="text/css" href="../../../common/prettify.css" /> - <script type="text/javascript" src="../../../common/prettify.js"></script> - </head> - <body onload="prettyPrint()"> - <h1>JMS Bridge Example</h1> - - <pre>To run the example, simply type <b>mvn verify</b> from this directory, <br>or <b>mvn -PnoServer verify</b> if you want to start and create the server manually.</pre> - - <p>This example shows you how to create a JMS Bridge between two ActiveMQ Artemis servers.</p> - <img src="jms-bridge.png" /> - <p>The example will use two ActiveMQ Artemis servers:</p> - <ul> - <li>Server #0 – the <em>Source</em> server. It will be configured with a JMS Topic bound to JNDI under <code>source/topic</code> - <li>Server #1 – the <em>Target</em> server. It will be configured with a JMS Queue bound to JNDI under <code>target/queue</code><br /> - </ul> - <p>Both ActiveMQ Artemis server will run their own JNDI server used by the JMS Bridge and the JMS Client to lookup JMS - resources (ConnectionFactory and Destination).</p> - <p>The JMS Bridge will be started in the example code and be configured to bridge messages from the <em>source</em> destination - (the topic hosted on server #0) and the <em>target</em> destination (the queue hosted on server #1)</p> - <p>The client will check the bridge works by:</p> - <ol> - <li>sending a message to the <em>source</em> topic</li> - <li>receive a message from the <em>target</em> queue</li> - <li>check that both messages correspond to the same content.</li> - </ol> - <h3>JMS Bridge Configuration</h3> - <p>The JMS Bridge is a <abbr title="Plain Old Java Object">POJO</abbr> that we configure with both source and target - JNDI configurations. In the actual example we are programmatically creating the Bridge, however the following section - describes how you would do this if you wanted to deploy with an actual ActiveMQ Artemis server via the activemq-beans.xml. - - <h4>Configuring the Bridge with the JBoss Microcontainer</h4> - <p> - in which we inject JNDI configurations - so that it looks up its source and target JMS resources. - The JMS Bridge is defined a bean and setup by JBoss Microntainer in the same VM than Server #1, the target server.</p> - - </p>The JMS Bridge sample configuration can be found in <code>resources/activemq-beans.xml</code>, firstly we define the - Bridge itself:</p> - <pre class="prettyprint"> - <!-- The JMS Bridge --> - <bean name="JMSBridge" class="org.apache.activemq.artemis.jms.bridge.impl.JMSBridgeImpl"> - ... - </bean> - </pre> - <p>the <code>JMSBridgeImpl</code> constructor is used to inject all the properties required to run the JMS Bridge.</p> - <p>Its first four arguments defines how the bridge will lookup:</p> - <ol> - <li>its <em>source</em> JMS ConnectionFactory</li> - <li>its <em>source</em> JMS Destination</li> - <li>its <em>target</em> JMS ConnectionFactory</li> - <li>its <em>target</em> JMS Destination</li> - </ol> - <p>Using other POJOs, the JMS Bridge is configured to retrieve:</p> - <ul> - <li>its <em>source</em> JMS ConnectionFactory by looking up <code>/source/ConnectionFactory</code> using - the <code>SourceJNDI</code> configuration</li> - <li>its <em>source</em> JMS Destination by looking up <code>/source/topic</code> using - the <code>SourceJNDI</code> configuration</li> - <li>its <em>target</em> JMS ConnectionFactory by looking up <code>/target/ConnectionFactory</code> using - the <code>TargetJNDI</code> configuration</li> - <li>its <em>target</em> JMS ConnectionFactory by looking up <code>/target/queue</code> using - the <code>TargetJNDI</code> configuration</li> - </ul> - <p>In turn, <code>SourceJNDI</code> and <code>TargetJNDI</code> are POJOs defining how to connect to JNDI server. - SourceJNDI URL must point to your source server, while LocalJNDI must point to your target server:</p> - <pre class="prettyprint"> - <bean name="SourceJNDI" class="java.util.Hashtable"> - ... - <entry> - <key>java.naming.provider.url</key> - <!-- **************************************** --> - <!-- Replace with the *source* server address --> - <!-- **************************************** --> - <value>jnp://192.168.0.10:1099</value> - ... - </bean> - <bean name="TargetJNDI" class="java.util.Hashtable"> - ... - <ntry> - <key>java.naming.provider.url</key> - <!-- **************************************** --> - <!-- Replace with the *target* server address --> - <!-- **************************************** --> - <value>jnp://1192.168.0.11:1099</value> - </entry> - ... - </bean> - </pre> - <h2>Example step-by-step</h2> - <p>To run the example after having setup both ActiveMQ Artemis servers and the JMS bridge:</p> - <ol> - <li>To run the example simply run <code>mvn verify -Pexample</code></li> - </ol> - <p>Let's look at the Client code (in <code>JMSBridgeExample</code> class):</p> - <ol> - <li>First we need to get an initial context so we can look-up the JMS resources</li> - <pre class="prettyprint"> - InitialContext sourceContext = createContext(sourceServer); - InitialContext targetContext = createContext(targetServer); - </pre> - <li>We then create a JMS Bridge and start it, Note, for certain quality of service modes such as - ONCE_AND_ONCE_ONLY and AT_LEAST_ONCE a Transaction Manager is required to ensure Messages are delivered - accordingly. A Transaction Manager can be either loaded via implementation of TransactionManagerLocator intefer - and loaded via standard a ServiceLoader or by explicitly setting an instance of a Transaction Manager on the - bridge using setTranscationManager(TransactionManager tm) method. In this example we'll be using the DUPLICATES_OK - quality of service so there is no need for a Transaction Manager. - <pre class="prettyprint"> - JMSBridge jmsBridge = new JMSBridgeImpl( - new JNDIConnectionFactoryFactory(sourceJndiParams, "source/ConnectionFactory"), - new JNDIConnectionFactoryFactory(targetJndiParams, "target/ConnectionFactory"), - new JNDIDestinationFactory(sourceJndiParams, "source/topic"), - new JNDIDestinationFactory(targetJndiParams, "target/queue"), - null, - null, - null, - null, - null, - 5000, - 10, - QualityOfServiceMode.DUPLICATES_OK, - 1, - -1, - null, - null, - true); - .... - jmsBridge.start(); - </pre> - <li>We look up the JMS resources from the Source server</li> - <pre class="prettyprint"> - ConnectionFactory sourceConnectionFactory = (ConnectionFactory)sourceContext.lookup("source/ConnectionFactory"); - Topic sourceTopic = (Topic)sourceContext.lookup("source/topic"); - </pre> - - <li>We create JMS objects to send a message to the source destination</li> - <pre class="prettyprint"> - sourceConnection = sourceConnectionFactory.createConnection(); - Session sourceSession = sourceConnection.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageProducer sourceProducer = sourceSession.createProducer(sourceTopic); - </pre> - - <li>We send a message to the source destination</li> - <pre class="prettyprint"> - TextMessage message = sourceSession.createTextMessage("this is a text message sent at " + System.currentTimeMillis()); - sourceProducer.send(message); - </pre> - - <li>We close the connection to the source server</li> - <pre class="prettyprint"> - sourceConnection.close(); - </pre> - - <p>At this point, the JMS Bridge will consume the message from the source topic and - sends it to the target queue. - The client will check the bridge works by consuming a message from the target queue.</p> - - <li>We look up the JMS resources from the target server</li> - <pre class="prettyprint"> - ConnectionFactory targetConnectionFactory = (ConnectionFactory)targetContext.lookup("target/ConnectionFactory"); - Queue targetQueue = (Queue)targetContext.lookup("target/queue"); - </pre> - - <li>We create JMS objects to receive a message from the target destination</li> - <pre class="prettyprint"> - targetConnection = targetConnectionFactory.createConnection(); - Session targetSession = targetConnection.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageConsumer targetConsumer = targetSession.createConsumer(targetQueue); - </pre> - - <li>We start the target connection to start receiving messages - <pre class="prettyprint"> - targetConnection.start(); - </pre> - - <li>We receive the message and print it. Its content is the same than the message - the client sent to the source topic</li> - <pre class="prettyprint"> - TextMessage messageReceived = (TextMessage)targetConsumer.receive(5000); - </pre> - - <li>We display the message ID and its "bridged" message ID</li> - <pre class="prettyprint"> - System.out.format("Message ID : %s\n", messageReceived.getJMSMessageID()); - System.out.format("Bridged Message ID : %s\n", messageReceived.getStringProperty("AMQ_BRIDGE_MSG_ID_LIST")); - </pre> - - <p>Note that the message received from the target queue is <em>not the same message</em> sent to the source topic - (their message IDs are different) but they have the <em>same content</em>. - - <li>And finally, we stop the Bridge and <b>always</b> remember to close your JMS connections and resources after use, in a <code>finally</code> block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects</li> - - <pre class="prettyprint"> - <code>finally - { - if (jmsBridge != null) - { - jmsBridge.stop(); - } - if (initialContext != null) - { - initialContext.close(); - } - if (connection != null) - { - connection.close(); - } - }</code> - </pre> - - - - </ol> - - <h2>More information</h2> - - <ul> - <li>User Manual's <a href="../../../docs/user-manual/en/html_single/appserver-integration.html#jms-bridge">JMS Bridge chapter</a></li> - <li>The <a href="../../javaee/jms-bridge/readme.html">Java EE JMS Bridge example</a> shows how to configure a JMS Bridge - inside JBoss Application Server to bridge destinations from the same server.</a> - </p> - - </body> -</html> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/jms-bridge/readme.md ---------------------------------------------------------------------- diff --git a/examples/features/standard/jms-bridge/readme.md b/examples/features/standard/jms-bridge/readme.md new file mode 100644 index 0000000..8001bcd --- /dev/null +++ b/examples/features/standard/jms-bridge/readme.md @@ -0,0 +1,24 @@ +# JMS Bridge Example + +To run the example, simply type **mvn verify** from this directory, or **mvn -PnoServer verify** if you want to start and create the broker manually. + +This example shows you how to create a JMS Bridge between two ActiveMQ Artemis brokers. + + + +The example will use two ActiveMQ Artemis brokers: + +* Server #0 â the _Source_ broker. It will be configured with a JMS Topic bound to JNDI under `source/topic` +* Server #1 â the _Target_ broker. It will be configured with a JMS Queue bound to JNDI under `target/queue` + +The JMS Bridge will be started in the example code and be configured to bridge messages from the _source_ destination (the topic hosted on broker #0) and the _target_ destination (the queue hosted on broker #1) + +The client will check the bridge works by: + +1. sending a message to the _source_ topic +2. receive a message from the _target_ queue +3. check that both messages correspond to the same content. + +### JMS Bridge Configuration + +The JMS Bridge is a POJO that we configure with both source and target JNDI configurations. In the actual example we are programmatically creating the Bridge. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/jms-bridge/src/main/java/org/apache/activemq/artemis/jms/example/JMSBridgeExample.java ---------------------------------------------------------------------- diff --git a/examples/features/standard/jms-bridge/src/main/java/org/apache/activemq/artemis/jms/example/JMSBridgeExample.java b/examples/features/standard/jms-bridge/src/main/java/org/apache/activemq/artemis/jms/example/JMSBridgeExample.java index 5b25a82..f7d22ca 100644 --- a/examples/features/standard/jms-bridge/src/main/java/org/apache/activemq/artemis/jms/example/JMSBridgeExample.java +++ b/examples/features/standard/jms-bridge/src/main/java/org/apache/activemq/artemis/jms/example/JMSBridgeExample.java @@ -127,7 +127,7 @@ public class JMSBridgeExample { jndiProps.put("connectionFactory.ConnectionFactory", server); jndiProps.put("java.naming.factory.initial", "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory"); jndiProps.put("queue.target/queue", "target"); - jndiProps.put("topic.source/topic", "topic"); + jndiProps.put("topic.source/topic", "source"); return jndiProps; } }
