http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/security/readme.html ---------------------------------------------------------------------- diff --git a/examples/broker-features/standard/security/readme.html b/examples/broker-features/standard/security/readme.html deleted file mode 100644 index d25dd42..0000000 --- a/examples/broker-features/standard/security/readme.html +++ /dev/null @@ -1,326 +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 Security 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 Security 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 how to configure and use security using ActiveMQ Artemis.</p> - - <p>With security properly configured, ActiveMQ Artemis can restrict client access to its resources, including - connection creation, message sending/receiving, etc. This is done by configuring users and roles as well as permissions in - the configuration files. </p> - - <p>ActiveMQ Artemis supports wild-card security configuration. This feature makes security configuration very - flexible and enables fine-grained control over permissions in an efficient way.</p> - - <p>For a full description of how to configure security with ActiveMQ Artemis, please consult the user - manual.</p> - - <p>This example demonstrates how to configure users/roles, how to configure topics with proper permissions using wild-card - expressions, and how they take effects in a simple program. </p> - - <p>First we need to configure users with roles. Users and Roles are configured in <code>activemq-users.xml</code>. This example has four users - configured as below </p> - - <pre class="prettyprint"> - <code> - <user name="bill" password="activemq"> - <role name="user"/> - </user> - - <user name="andrew" password="activemq1"> - <role name="europe-user"/> - <role name="user"/> - </user> - - <user name="frank" password="activemq2"> - <role name="us-user"/> - <role name="news-user"/> - <role name="user"/> - </user> - - <user name="sam" password="activemq3"> - <role name="news-user"/> - <role name="user"/> - </user> - </code> - </pre> - - <p> - Each user has three properties available: user name, password, and roles it belongs to. It should be noted that - a user can belong to more than one role. In the above configuration, all users belong to role 'user'. User 'andrew' also - belongs to role 'europe-user', user 'frank' also belongs to 'us-user' and 'news-user' and user 'sam' also belongs to 'news-user'. - </p> - <p> - User name and password consists of a valid account that can be used to establish connections to a ActiveMQ Artemis server, while - roles are used in controlling the access privileges against ActiveMQ Artemis topics and queues. You can achieve this control by - configuring proper permissions in <code>broker.xml</code>, like the following - </p> - <pre class="prettyprint"><code> - <security-settings> - <!-- any user can have full control of generic topics --> - <security-setting match="jms.topic.#"> - <permission type="createDurableQueue" roles="user"/> - <permission type="deleteDurableQueue" roles="user"/> - <permission type="createNonDurableQueue" roles="user"/> - <permission type="deleteNonDurableQueue" roles="user"/> - <permission type="send" roles="user"/> - <permission type="consume" roles="user"/> - </security-setting> - - <security-setting match="jms.topic.news.europe.#"> - <permission type="createDurableQueue" roles="user"/> - <permission type="deleteDurableQueue" roles="user"/> - <permission type="createNonDurableQueue" roles="user"/> - <permission type="deleteNonDurableQueue" roles="user"/> - <permission type="send" roles="europe-user"/> - <permission type="consume" roles="news-user"/> - </security-setting> - - <security-setting match="jms.topic.news.us.#"> - <permission type="createDurableQueue" roles="user"/> - <permission type="deleteDurableQueue" roles="user"/> - <permission type="createNonDurableQueue" roles="user"/> - <permission type="deleteNonDurableQueue" roles="user"/> - <permission type="send" roles="us-user"/> - <permission type="consume" roles="news-user"/> - </security-setting> - </security-settings> - </code></pre> - - <p>Permissions can be defined on any group of queues, by using a wildcard. You can easily specify - wildcards to apply certain permissions to a set of matching queues and topics. In the above configuration - we have created four sets of permissions, each set matches against a special group of targets, indicated by wild-card match attributes.</p> - - <p>You can provide a very broad permission control as a default and then add more strict control - over specific addresses. By the above we define the following access rules:</p> - - <li>Only role 'us-user' can create/delete and pulish messages to topics whose names match wild-card pattern 'news.us.#'.</li> - <li>Only role 'europe-user' can create/delete and publish messages to topics whose names match wild-card pattern 'news.europe.#'.</li> - <li>Only role 'news-user' can subscribe messages to topics whose names match wild-card pattern 'news.us.#' and 'news.europe.#'.</li> - <li>For any other topics that don't match any of the above wild-card patterns, permissions are granted to users of role 'user'.</li> - - <p>To illustrate the effect of permissions, three topics are deployed. Topic 'genericTopic' matches 'jms.topic.#' wild-card, topic 'news.europe.europeTopic' matches - jms.topic.news.europe.#' wild-cards, and topic 'news.us.usTopic' matches 'jms.topic.news.us.#'.</p> - - <p>With ActiveMQ Artemis, the security manager is also configurable. You can use JAASSecurityManager or JBossASSecurityManager based on you need. Please - check out the activemq-beans.xml for how to do. In this example we just use the basic ActiveMQSecurityManagerImpl which reads users/roles/passwords from the xml - file <code>activemq-users.xml</code>. - - - <h2>Example step-by-step</h2> - <p><i>To run the example, simply type <code>mvn verify -Pexample</code> from this directory</i></p> - - <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(0); - </code> - </pre> - - <li>We perform lookup on the topics</li> - <pre class="prettyprint"> - <code> - Topic genericTopic = (Topic) initialContext.lookup("/topic/genericTopic"); - Topic europeTopic = (Topic) initialContext.lookup("/topic/europeTopic"); - Topic usTopic = (Topic) initialContext.lookup("/topic/usTopic"); - </code> - </pre> - - <li>We perform a lookup on the Connection Factory</li> - <pre class="prettyprint"> - <code> - ConnectionFactory cf = (ConnectionFactory) initialContext.lookup("/ConnectionFactory"); - </code> - </pre> - - <li>We try to create a JMS Connection without user/password. It will fail.</li> - <pre class="prettyprint"> - <code> - try - { - cf.createConnection(); - result = false; - } - catch (JMSSecurityException e) - { - System.out.println("Default user cannot get a connection. Details: " + e.getMessage()); - } - </code> - </pre> - - <li>Bill tries to make a connection using wrong password</li> - <pre class="prettyprint"> - <code> - billConnection = null; - try - { - billConnection = createConnection("bill", "activemq1", cf); - result = false; - } - catch (JMSException e) - { - System.out.println("User bill failed to connect. Details: " + e.getMessage()); - } - </code> - </pre> - - <li>Bill makes a good connection.</li> - <pre class="prettyprint"> - <code> - billConnection = createConnection("bill", "activemq", cf); - billConnection.start(); - </code> - </pre> - - <li>Andrew makes a good connection</li> - <pre class="prettyprint"> - <code> - andrewConnection = createConnection("andrew", "activemq1", cf); - andrewConnection.start(); - </code> - </pre> - - <li>Frank makes a good connection</li> - <pre class="prettyprint"> - <code> - frankConnection = createConnection("frank", "activemq2", cf); - frankConnection.start(); - </code> - </pre> - - <li>Sam makes a good connection</li> - <pre class="prettyprint"> - <code> - samConnection = createConnection("sam", "activemq3", cf); - samConnection.start(); - </code> - </pre> - - <li>We check every user can publish/subscribe genericTopics</li> - <pre class="prettyprint"> - <code> - checkUserSendAndReceive(genericTopic, billConnection, "bill"); - checkUserSendAndReceive(genericTopic, andrewConnection, "andrew"); - checkUserSendAndReceive(genericTopic, frankConnection, "frank"); - checkUserSendAndReceive(genericTopic, samConnection, "sam"); - </code> - </pre> - - <li>We check permissions on news.europe.europeTopic for bill: can't send and can't receive</li> - <pre class="prettyprint"> - <code> - checkUserNoSendNoReceive(europeTopic, billConnection, "bill", andrewConnection, frankConnection); - </code> - </pre> - - <li>We check permissions on news.europe.europeTopic for andrew: can send but can't receive</li> - <pre class="prettyprint"> - <code> - checkUserSendNoReceive(europeTopic, andrewConnection, "andrew", frankConnection); - </code> - </pre> - - <li>We check permissions on news.europe.europeTopic for frank: can't send but can receive</li> - <pre class="prettyprint"> - <code> - checkUserReceiveNoSend(europeTopic, frankConnection, "frank", andrewConnection); - </code> - </pre> - - <li>We check permissions on news.europe.europeTopic for sam: can't send but can receive</li> - <pre class="prettyprint"> - <code> - checkUserReceiveNoSend(europeTopic, samConnection, "sam", andrewConnection); - </code> - </pre> - - <li>We check permissions on news.us.usTopic for bill: can't send and can't receive</li> - <pre class="prettyprint"> - <code> - checkUserNoSendNoReceive(usTopic, billConnection, "bill"); - </code> - </pre> - - <li>We check permissions on news.us.usTopic for andrew: can't send and can't receive</li> - <pre class="prettyprint"> - <code> - checkUserNoSendNoReceive(usTopic, andrewConnection, "andrew"); - </code> - </pre> - - <li>We check permissions on news.us.usTopic for frank: can both send and receive</li> - <pre class="prettyprint"> - <code> - checkUserSendAndReceive(usTopic, frankConnection, "frank"); - </code> - </pre> - - <li>We check permissions on news.us.usTopic for sam: can't send but can receive</li> - <pre class="prettyprint"> - <code> - checkUserReceiveNoSend(usTopic, samConnection, "sam", frankConnection); - </code> - </pre> - - <li>And finally, <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 (billConnection != null) - { - billConnection.close(); - } - if (andrewConnection != null) - { - andrewConnection.close(); - } - if (frankConnection != null) - { - frankConnection.close(); - } - if (samConnection != null) - { - samConnection.close(); - } - - // Also the initialContext - if (initialContext != null) - { - initialContext.close(); - } - } - </code> - </pre> - </ol> - </body> -</html>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/security/src/main/java/org/apache/activemq/artemis/jms/example/SecurityExample.java ---------------------------------------------------------------------- diff --git a/examples/broker-features/standard/security/src/main/java/org/apache/activemq/artemis/jms/example/SecurityExample.java b/examples/broker-features/standard/security/src/main/java/org/apache/activemq/artemis/jms/example/SecurityExample.java deleted file mode 100644 index 88fd1da..0000000 --- a/examples/broker-features/standard/security/src/main/java/org/apache/activemq/artemis/jms/example/SecurityExample.java +++ /dev/null @@ -1,282 +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.jms.example; - -import javax.jms.Connection; -import javax.jms.ConnectionFactory; -import javax.jms.JMSException; -import javax.jms.JMSSecurityException; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.Session; -import javax.jms.TextMessage; -import javax.jms.Topic; -import javax.naming.InitialContext; - -public class SecurityExample { - - public static void main(final String[] args) throws Exception { - boolean result = true; - Connection failConnection = null; - Connection billConnection = null; - Connection andrewConnection = null; - Connection frankConnection = null; - Connection samConnection = null; - - InitialContext initialContext = null; - try { - // /Step 1. Create an initial context to perform the JNDI lookup. - initialContext = new InitialContext(); - - // Step 2. perform lookup on the topics - Topic genericTopic = (Topic) initialContext.lookup("topic/genericTopic"); - Topic europeTopic = (Topic) initialContext.lookup("topic/europeTopic"); - Topic usTopic = (Topic) initialContext.lookup("topic/usTopic"); - - // Step 3. perform a lookup on the Connection Factory - ConnectionFactory cf = (ConnectionFactory) initialContext.lookup("ConnectionFactory"); - - // Step 4. Try to create a JMS Connection without user/password. It will fail. - try { - failConnection = cf.createConnection(); - result = false; - } - catch (JMSSecurityException e) { - System.out.println("Default user cannot get a connection. Details: " + e.getMessage()); - } - - // Step 5. bill tries to make a connection using wrong password - billConnection = null; - try { - billConnection = createConnection("bill", "activemq1", cf); - result = false; - } - catch (JMSException e) { - System.out.println("User bill failed to connect. Details: " + e.getMessage()); - } - - // Step 6. bill makes a good connection. - billConnection = createConnection("bill", "activemq", cf); - billConnection.start(); - - // Step 7. andrew makes a good connection. - andrewConnection = createConnection("andrew", "activemq1", cf); - andrewConnection.start(); - - // Step 8. frank makes a good connection. - frankConnection = createConnection("frank", "activemq2", cf); - frankConnection.start(); - - // Step 9. sam makes a good connection. - samConnection = createConnection("sam", "activemq3", cf); - samConnection.start(); - - // Step 10. Check every user can publish/subscribe genericTopics. - System.out.println("------------------------Checking permissions on " + genericTopic + "----------------"); - checkUserSendAndReceive(genericTopic, billConnection, "bill"); - checkUserSendAndReceive(genericTopic, andrewConnection, "andrew"); - checkUserSendAndReceive(genericTopic, frankConnection, "frank"); - checkUserSendAndReceive(genericTopic, samConnection, "sam"); - System.out.println("-------------------------------------------------------------------------------------"); - - System.out.println("------------------------Checking permissions on " + europeTopic + "----------------"); - - // Step 11. Check permissions on news.europe.europeTopic for bill: can't send and can't receive - checkUserNoSendNoReceive(europeTopic, billConnection, "bill"); - - // Step 12. Check permissions on news.europe.europeTopic for andrew: can send but can't receive - checkUserSendNoReceive(europeTopic, andrewConnection, "andrew", frankConnection); - - // Step 13. Check permissions on news.europe.europeTopic for frank: can't send but can receive - checkUserReceiveNoSend(europeTopic, frankConnection, "frank", andrewConnection); - - // Step 14. Check permissions on news.europe.europeTopic for sam: can't send but can receive - checkUserReceiveNoSend(europeTopic, samConnection, "sam", andrewConnection); - System.out.println("-------------------------------------------------------------------------------------"); - - System.out.println("------------------------Checking permissions on " + usTopic + "----------------"); - - // Step 15. Check permissions on news.us.usTopic for bill: can't send and can't receive - checkUserNoSendNoReceive(usTopic, billConnection, "bill"); - - // Step 16. Check permissions on news.us.usTopic for andrew: can't send and can't receive - checkUserNoSendNoReceive(usTopic, andrewConnection, "andrew"); - - // Step 17. Check permissions on news.us.usTopic for frank: can both send and receive - checkUserSendAndReceive(usTopic, frankConnection, "frank"); - - // Step 18. Check permissions on news.us.usTopic for sam: can't send but can receive - checkUserReceiveNoSend(usTopic, samConnection, "sam", frankConnection); - System.out.println("-------------------------------------------------------------------------------------"); - } - finally { - // Step 19. Be sure to close our JMS resources! - if (failConnection != null) { - failConnection.close(); - } - if (billConnection != null) { - billConnection.close(); - } - if (andrewConnection != null) { - andrewConnection.close(); - } - if (frankConnection != null) { - frankConnection.close(); - } - if (samConnection != null) { - samConnection.close(); - } - - // Also the initialContext - if (initialContext != null) { - initialContext.close(); - } - } - } - - // Check the user can receive message but cannot send message. - private static void checkUserReceiveNoSend(final Topic topic, - final Connection connection, - final String user, - final Connection sendingConn) throws JMSException { - Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageProducer producer = session.createProducer(topic); - MessageConsumer consumer = session.createConsumer(topic); - TextMessage msg = session.createTextMessage("hello-world-1"); - - try { - producer.send(msg); - throw new IllegalStateException("Security setting is broken! User " + user + - " can send message [" + - msg.getText() + - "] to topic " + - topic); - } - catch (JMSException e) { - System.out.println("User " + user + " cannot send message [" + msg.getText() + "] to topic: " + topic); - } - - // Now send a good message - Session session1 = sendingConn.createSession(false, Session.AUTO_ACKNOWLEDGE); - producer = session1.createProducer(topic); - producer.send(msg); - - TextMessage receivedMsg = (TextMessage) consumer.receive(2000); - - if (receivedMsg != null) { - System.out.println("User " + user + " can receive message [" + receivedMsg.getText() + "] from topic " + topic); - } - else { - throw new IllegalStateException("Security setting is broken! User " + user + " cannot receive message from topic " + topic); - } - - session1.close(); - session.close(); - } - - // Check the user can send message but cannot receive message - private static void checkUserSendNoReceive(final Topic topic, - final Connection connection, - final String user, - final Connection receivingConn) throws JMSException { - Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageProducer producer = session.createProducer(topic); - try { - session.createConsumer(topic); - } - catch (JMSException e) { - System.out.println("User " + user + " cannot receive any message from topic " + topic); - } - - Session session1 = receivingConn.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageConsumer goodConsumer = session1.createConsumer(topic); - - TextMessage msg = session.createTextMessage("hello-world-2"); - producer.send(msg); - - TextMessage receivedMsg = (TextMessage) goodConsumer.receive(2000); - if (receivedMsg != null) { - System.out.println("User " + user + " can send message [" + receivedMsg.getText() + "] to topic " + topic); - } - else { - throw new IllegalStateException("Security setting is broken! User " + user + - " cannot send message [" + - msg.getText() + - "] to topic " + - topic); - } - - session.close(); - session1.close(); - } - - // Check the user has neither send nor receive permission on topic - private static void checkUserNoSendNoReceive(final Topic topic, - final Connection connection, - final String user) throws JMSException { - Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageProducer producer = session.createProducer(topic); - - try { - session.createConsumer(topic); - } - catch (JMSException e) { - System.out.println("User " + user + " cannot create consumer on topic " + topic); - } - - TextMessage msg = session.createTextMessage("hello-world-3"); - try { - producer.send(msg); - throw new IllegalStateException("Security setting is broken! User " + user + - " can send message [" + - msg.getText() + - "] to topic " + - topic); - } - catch (JMSException e) { - System.out.println("User " + user + " cannot send message [" + msg.getText() + "] to topic: " + topic); - } - - session.close(); - } - - // Check the user connection has both send and receive permissions on the topic - private static void checkUserSendAndReceive(final Topic topic, - final Connection connection, - final String user) throws JMSException { - Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - TextMessage msg = session.createTextMessage("hello-world-4"); - MessageProducer producer = session.createProducer(topic); - MessageConsumer consumer = session.createConsumer(topic); - producer.send(msg); - TextMessage receivedMsg = (TextMessage) consumer.receive(5000); - if (receivedMsg != null) { - System.out.println("User " + user + " can send message: [" + msg.getText() + "] to topic: " + topic); - System.out.println("User " + user + " can receive message: [" + msg.getText() + "] from topic: " + topic); - } - else { - throw new IllegalStateException("Error! User " + user + " cannot receive the message! "); - } - session.close(); - } - - private static Connection createConnection(final String username, - final String password, - final ConnectionFactory cf) throws JMSException { - return cf.createConnection(username, password); - } -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/security/src/main/resources/activemq/server0/artemis-roles.properties ---------------------------------------------------------------------- diff --git a/examples/broker-features/standard/security/src/main/resources/activemq/server0/artemis-roles.properties b/examples/broker-features/standard/security/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 09b3f5d..0000000 --- a/examples/broker-features/standard/security/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,20 +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. -## --------------------------------------------------------------------------- -bill=user -andrew=europe-user,user -frank=us-user,news-user,user -sam=news-user,user \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/security/src/main/resources/activemq/server0/artemis-users.properties ---------------------------------------------------------------------- diff --git a/examples/broker-features/standard/security/src/main/resources/activemq/server0/artemis-users.properties b/examples/broker-features/standard/security/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 0a206c6..0000000 --- a/examples/broker-features/standard/security/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,20 +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. -## --------------------------------------------------------------------------- -bill=activemq -andrew=activemq1 -frank=activemq2 -sam=activemq3 \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/security/src/main/resources/activemq/server0/broker.xml ---------------------------------------------------------------------- diff --git a/examples/broker-features/standard/security/src/main/resources/activemq/server0/broker.xml b/examples/broker-features/standard/security/src/main/resources/activemq/server0/broker.xml deleted file mode 100644 index 6a8b82b..0000000 --- a/examples/broker-features/standard/security/src/main/resources/activemq/server0/broker.xml +++ /dev/null @@ -1,81 +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:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns="urn:activemq" - xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> - - <jms xmlns="urn:activemq:jms"> - <topic name="genericTopic"/> - - <topic name="news.europe.europeTopic"/> - - <topic name="news.us.usTopic"/> - </jms> - - <core xmlns="urn:activemq:core"> - - <bindings-directory>${data.dir}/server0/data/messaging/bindings</bindings-directory> - - <journal-directory>${data.dir}/server0/data/messaging/journal</journal-directory> - - <large-messages-directory>${data.dir}/server0/data/messaging/largemessages</large-messages-directory> - - <paging-directory>${data.dir}/server0/data/messaging/paging</paging-directory> - - <!-- Acceptors --> - <acceptors> - <acceptor name="netty-acceptor">tcp://localhost:61616</acceptor> - </acceptors> - - <!-- Other config --> - - <security-settings> - <!-- any user can have full control of generic topics --> - <security-setting match="jms.topic.#"> - <permission type="createDurableQueue" roles="user"/> - <permission type="deleteDurableQueue" roles="user"/> - <permission type="createNonDurableQueue" roles="user"/> - <permission type="deleteNonDurableQueue" roles="user"/> - <permission type="send" roles="user"/> - <permission type="consume" roles="user"/> - </security-setting> - - <security-setting match="jms.topic.news.europe.#"> - <permission type="createDurableQueue" roles="user"/> - <permission type="deleteDurableQueue" roles="user"/> - <permission type="createNonDurableQueue" roles="user"/> - <permission type="deleteNonDurableQueue" roles="user"/> - <permission type="send" roles="europe-user"/> - <permission type="consume" roles="news-user"/> - </security-setting> - - <security-setting match="jms.topic.news.us.#"> - <permission type="createDurableQueue" roles="user"/> - <permission type="deleteDurableQueue" roles="user"/> - <permission type="createNonDurableQueue" roles="user"/> - <permission type="deleteNonDurableQueue" roles="user"/> - <permission type="send" roles="us-user"/> - <permission type="consume" roles="news-user"/> - </security-setting> - </security-settings> - - </core> -</configuration> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/security/src/main/resources/jndi.properties ---------------------------------------------------------------------- diff --git a/examples/broker-features/standard/security/src/main/resources/jndi.properties b/examples/broker-features/standard/security/src/main/resources/jndi.properties deleted file mode 100644 index 0a3b640..0000000 --- a/examples/broker-features/standard/security/src/main/resources/jndi.properties +++ /dev/null @@ -1,22 +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. - -java.naming.factory.initial=org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory -connectionFactory.ConnectionFactory=tcp://localhost:61616 -topic.topic/genericTopic=genericTopic -topic.topic/europeTopic=news.europe.europeTopic -topic.topic/usTopic=news.us.usTopic http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/send-acknowledgements/pom.xml ---------------------------------------------------------------------- diff --git a/examples/broker-features/standard/send-acknowledgements/pom.xml b/examples/broker-features/standard/send-acknowledgements/pom.xml deleted file mode 100644 index 8295cdc..0000000 --- a/examples/broker-features/standard/send-acknowledgements/pom.xml +++ /dev/null @@ -1,104 +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>1.0.1-SNAPSHOT</version> - </parent> - - <artifactId>send-acknowledgements</artifactId> - <packaging>jar</packaging> - <name>ActiveMQ Artemis JMS Send Acknowledgements Example</name> - - <properties> - <activemq.basedir>${project.basedir}/../../../..</activemq.basedir> - </properties> - - <dependencies> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-jms-client</artifactId> - <version>${project.version}</version> - </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> - </execution> - <execution> - <id>start</id> - <goals> - <goal>cli</goal> - </goals> - <configuration> - <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.jms.example.SendAcknowledgementsExample</clientClass> - </configuration> - </execution> - <execution> - <id>stop</id> - <goals> - <goal>cli</goal> - </goals> - <configuration> - <args> - <param>stop</param> - </args> - </configuration> - </execution> - </executions> - <dependencies> - <dependency> - <groupId>org.apache.activemq.examples.broker</groupId> - <artifactId>send-acknowledgements</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> - </plugin> - </plugins> - </build> - -</project> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/send-acknowledgements/readme.html ---------------------------------------------------------------------- diff --git a/examples/broker-features/standard/send-acknowledgements/readme.html b/examples/broker-features/standard/send-acknowledgements/readme.html deleted file mode 100644 index fcc37fc..0000000 --- a/examples/broker-features/standard/send-acknowledgements/readme.html +++ /dev/null @@ -1,140 +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 Asynchronous Send Acknowledgements 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>Asynchronous Send Acknowledgements 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>Asynchronous Send Acknowledgements are an advanced feature of ActiveMQ Artemis which allow you to - receive acknowledgements that messages were successfully received at the server in a separate thread to the sending thread<p/> - <p>In this example we create a normal JMS session, then set a SendAcknowledgementHandler on the JMS - session's underlying core session. We send many messages to the server without blocking and asynchronously - receive send acknowledgements via the SendAcknowledgementHandler. - - <p>For more information on Asynchronous Send Acknowledgements please see the user manual</p> - <h2>Example step-by-step</h2> - <p><i>To run the example, simply type <code>mvn verify -Pexample</code> from this directory</i></p> - - <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 connection</li> - <pre class="prettyprint"> - <code>connection = cf.createConnection();</code> - </pre> - - <li>Define a SendAcknowledgementHandler which will receive asynchronous acknowledgements</li> - <pre class="prettyprint"> - <code> - class MySendAcknowledgementsHandler implements SendAcknowledgementHandler - { - int count = 0; - - public void sendAcknowledged(final Message message) - { - System.out.println("Received send acknowledgement for message " + count++); - } - } - </code> - </pre> - - <li>Create a JMS session</li> - <pre class="prettyprint"> - <code>Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);</code> - </pre> - - <li>Set the handler on the underlying core session</li> - <pre class="prettyprint"> - <code> - ClientSession coreSession = ((ActiveMQSession)session).getCoreSession(); - - coreSession.setSendAcknowledgementHandler(new MySendAcknowledgementsHandler()); - - </code> - </pre> - - <li>Create a JMS Message Producer</li> - <pre class="prettyprint"> - <code> - MessageProducer producer = session.createProducer(queue); - - producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT); - </code> - </pre> - - <li>Send 5000 messages, the handler will get called asynchronously some time later after the messages are sent.</li> - <pre class="prettyprint"> - <code> - final int numMessages = 5000; - - for (int i = 0; i < numMessages; i++) - { - javax.jms.Message jmsMessage = session.createMessage(); - - producer.send(jmsMessage); - - System.out.println("Sent message " + i); - } - </code> - </pre> - - - <li>And finally, <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 (initialContext != null) - { - initialContext.close(); - } - if (connection != null) - { - connection.close(); - } - }</code> - </pre> - - - - </ol> - </body> -</html> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/send-acknowledgements/src/main/java/org/apache/activemq/artemis/jms/example/SendAcknowledgementsExample.java ---------------------------------------------------------------------- diff --git a/examples/broker-features/standard/send-acknowledgements/src/main/java/org/apache/activemq/artemis/jms/example/SendAcknowledgementsExample.java b/examples/broker-features/standard/send-acknowledgements/src/main/java/org/apache/activemq/artemis/jms/example/SendAcknowledgementsExample.java deleted file mode 100644 index 578d198..0000000 --- a/examples/broker-features/standard/send-acknowledgements/src/main/java/org/apache/activemq/artemis/jms/example/SendAcknowledgementsExample.java +++ /dev/null @@ -1,104 +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.jms.example; - -import javax.jms.Connection; -import javax.jms.ConnectionFactory; -import javax.jms.DeliveryMode; -import javax.jms.MessageProducer; -import javax.jms.Queue; -import javax.jms.Session; -import javax.naming.InitialContext; - -import org.apache.activemq.artemis.api.core.Message; -import org.apache.activemq.artemis.api.core.client.ClientSession; -import org.apache.activemq.artemis.api.core.client.SendAcknowledgementHandler; -import org.apache.activemq.artemis.jms.client.ActiveMQSession; - -/** - * Asynchronous Send Acknowledgements are an advanced feature of ActiveMQ Artemis which allow you to - * receive acknowledgements that messages were successfully received at the server in a separate stream - * to the stream of messages being sent to the server. - * For more information please see the readme.html file - */ -public class SendAcknowledgementsExample { - - public static void main(final String[] args) throws Exception { - Connection connection = null; - InitialContext initialContext = null; - try { - // Step 1. Create an initial context to perform the JNDI lookup. - initialContext = new InitialContext(); - - // Step 2. Perfom a lookup on the queue - Queue queue = (Queue) initialContext.lookup("queue/exampleQueue"); - - // Step 3. Perform a lookup on the Connection Factory - ConnectionFactory cf = (ConnectionFactory) initialContext.lookup("ConnectionFactory"); - - // Step 4. Create a JMS Connection - connection = cf.createConnection(); - - // Step 5. Define a SendAcknowledgementHandler which will receive asynchronous acknowledgements - class MySendAcknowledgementsHandler implements SendAcknowledgementHandler { - - int count = 0; - - public void sendAcknowledged(final Message message) { - System.out.println("Received send acknowledgement for message " + count++); - } - } - - // Step 6. Create a JMS Session - Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - - // Step 7. Set the handler on the underlying core session - - ClientSession coreSession = ((ActiveMQSession) session).getCoreSession(); - - coreSession.setSendAcknowledgementHandler(new MySendAcknowledgementsHandler()); - - // Step 6. Create a JMS Message Producer - MessageProducer producer = session.createProducer(queue); - - producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT); - - // Step 7. Send 5000 messages, the handler will get called asynchronously some time later after the messages - // are sent. - - final int numMessages = 5000; - - for (int i = 0; i < numMessages; i++) { - javax.jms.Message jmsMessage = session.createMessage(); - - producer.send(jmsMessage); - - System.out.println("Sent message " + i); - } - } - finally { - // Step 12. Be sure to close our JMS resources! - if (initialContext != null) { - initialContext.close(); - } - - if (connection != null) { - connection.close(); - } - } - } -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/send-acknowledgements/src/main/resources/jndi.properties ---------------------------------------------------------------------- diff --git a/examples/broker-features/standard/send-acknowledgements/src/main/resources/jndi.properties b/examples/broker-features/standard/send-acknowledgements/src/main/resources/jndi.properties deleted file mode 100644 index 8421f25..0000000 --- a/examples/broker-features/standard/send-acknowledgements/src/main/resources/jndi.properties +++ /dev/null @@ -1,20 +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. - -java.naming.factory.initial=org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory -connectionFactory.ConnectionFactory=tcp://localhost:61616?confirmationWindowSize=1048576 -queue.queue/exampleQueue=exampleQueue http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/spring-integration/pom.xml ---------------------------------------------------------------------- diff --git a/examples/broker-features/standard/spring-integration/pom.xml b/examples/broker-features/standard/spring-integration/pom.xml deleted file mode 100644 index 238a550..0000000 --- a/examples/broker-features/standard/spring-integration/pom.xml +++ /dev/null @@ -1,82 +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>1.0.1-SNAPSHOT</version> - </parent> - - <artifactId>spring-integration</artifactId> - <packaging>jar</packaging> - <name>ActiveMQ Artemis JMS Spring Integration Example</name> - - <properties> - <activemq.basedir>${project.basedir}/../../../..</activemq.basedir> - </properties> - - <dependencies> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-spring-integration</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.geronimo.specs</groupId> - <artifactId>geronimo-jms_2.0_spec</artifactId> - </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-context</artifactId> - </dependency> - </dependencies> - - <build> - <plugins> - <plugin> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-maven-plugin</artifactId> - <executions> - <execution> - <id>runClient</id> - <goals> - <goal>runClient</goal> - </goals> - <configuration> - <clientClass>org.apache.activemq.artemis.jms.example.SpringExample</clientClass> - </configuration> - </execution> - </executions> - <dependencies> - <dependency> - <groupId>org.apache.activemq.examples.broker</groupId> - <artifactId>spring-integration</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> - </plugin> - </plugins> - </build> - -</project> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/spring-integration/readme.html ---------------------------------------------------------------------- diff --git a/examples/broker-features/standard/spring-integration/readme.html b/examples/broker-features/standard/spring-integration/readme.html deleted file mode 100644 index a3855d0..0000000 --- a/examples/broker-features/standard/spring-integration/readme.html +++ /dev/null @@ -1,36 +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 Spring 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>ActiveMQ Artemis Spring Example</h1> - - <p>This examples shows how to setup and run an embedded JMS server within a Spring ApplicationContext using ActiveMQ Artemis along with ActiveMQ Artemis configuration files.</p> - - <h2>Example step-by-step</h2> - <p><i><b>YOU MUST DOWNLOAD THE SPRING LIBRARIES TO RUN THIS EXAMPLE!!!</b> You must also modify the build.xml file to include the spring jars. You'll see the placeholder that is already there.</i></p> - <p><i>To run the example, simply type <code>mvn verify -Pexample</code> from this directory</i></p> - </body> -</html> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/spring-integration/src/main/java/org/apache/activemq/artemis/jms/example/ExampleListener.java ---------------------------------------------------------------------- diff --git a/examples/broker-features/standard/spring-integration/src/main/java/org/apache/activemq/artemis/jms/example/ExampleListener.java b/examples/broker-features/standard/spring-integration/src/main/java/org/apache/activemq/artemis/jms/example/ExampleListener.java deleted file mode 100644 index 3d4e063..0000000 --- a/examples/broker-features/standard/spring-integration/src/main/java/org/apache/activemq/artemis/jms/example/ExampleListener.java +++ /dev/null @@ -1,37 +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.jms.example; - -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.MessageListener; -import javax.jms.TextMessage; - -public class ExampleListener implements MessageListener { - - protected static String lastMessage = null; - - public void onMessage(Message message) { - try { - lastMessage = ((TextMessage) message).getText(); - } - catch (JMSException e) { - throw new RuntimeException(e); - } - System.out.println("MESSAGE RECEIVED: " + lastMessage); - } -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/spring-integration/src/main/java/org/apache/activemq/artemis/jms/example/MessageSender.java ---------------------------------------------------------------------- diff --git a/examples/broker-features/standard/spring-integration/src/main/java/org/apache/activemq/artemis/jms/example/MessageSender.java b/examples/broker-features/standard/spring-integration/src/main/java/org/apache/activemq/artemis/jms/example/MessageSender.java deleted file mode 100644 index 594c69b..0000000 --- a/examples/broker-features/standard/spring-integration/src/main/java/org/apache/activemq/artemis/jms/example/MessageSender.java +++ /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. - */ -package org.apache.activemq.artemis.jms.example; - -import javax.jms.Connection; -import javax.jms.ConnectionFactory; -import javax.jms.Destination; -import javax.jms.JMSException; -import javax.jms.MessageProducer; -import javax.jms.Session; -import javax.jms.TextMessage; - -public class MessageSender { - - private ConnectionFactory connectionFactory; - private Destination destination; - - public ConnectionFactory getConnectionFactory() { - return connectionFactory; - } - - public void setConnectionFactory(ConnectionFactory connectionFactory) { - this.connectionFactory = connectionFactory; - } - - public Destination getDestination() { - return destination; - } - - public void setDestination(Destination destination) { - this.destination = destination; - } - - public void send(String msg) { - Connection conn = null; - try { - conn = connectionFactory.createConnection(); - Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageProducer producer = session.createProducer(destination); - TextMessage message = session.createTextMessage(msg); - producer.send(message); - } - catch (Exception ex) { - ex.printStackTrace(); - } - finally { - if (conn != null) { - try { - conn.close(); - } - catch (JMSException e) { - e.printStackTrace(); - } - } - } - } -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/spring-integration/src/main/java/org/apache/activemq/artemis/jms/example/SpringExample.java ---------------------------------------------------------------------- diff --git a/examples/broker-features/standard/spring-integration/src/main/java/org/apache/activemq/artemis/jms/example/SpringExample.java b/examples/broker-features/standard/spring-integration/src/main/java/org/apache/activemq/artemis/jms/example/SpringExample.java deleted file mode 100644 index cf3ec49..0000000 --- a/examples/broker-features/standard/spring-integration/src/main/java/org/apache/activemq/artemis/jms/example/SpringExample.java +++ /dev/null @@ -1,32 +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.jms.example; - -import org.springframework.context.support.ClassPathXmlApplicationContext; - -public class SpringExample { - - public static void main(String[] args) throws Exception { - System.out.println("Creating bean factory..."); - ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"spring-jms-beans.xml"}); - MessageSender sender = (MessageSender) context.getBean("MessageSender"); - System.out.println("Sending message..."); - sender.send("Hello world"); - Thread.sleep(100); - context.destroy(); - } -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/spring-integration/src/main/resources/artemis-roles.properties ---------------------------------------------------------------------- diff --git a/examples/broker-features/standard/spring-integration/src/main/resources/artemis-roles.properties b/examples/broker-features/standard/spring-integration/src/main/resources/artemis-roles.properties deleted file mode 100644 index 4e2d44c..0000000 --- a/examples/broker-features/standard/spring-integration/src/main/resources/artemis-roles.properties +++ /dev/null @@ -1,17 +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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/spring-integration/src/main/resources/artemis-users.properties ---------------------------------------------------------------------- diff --git a/examples/broker-features/standard/spring-integration/src/main/resources/artemis-users.properties b/examples/broker-features/standard/spring-integration/src/main/resources/artemis-users.properties deleted file mode 100644 index 4e2d44c..0000000 --- a/examples/broker-features/standard/spring-integration/src/main/resources/artemis-users.properties +++ /dev/null @@ -1,17 +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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/spring-integration/src/main/resources/broker.xml ---------------------------------------------------------------------- diff --git a/examples/broker-features/standard/spring-integration/src/main/resources/broker.xml b/examples/broker-features/standard/spring-integration/src/main/resources/broker.xml deleted file mode 100644 index 2970329..0000000 --- a/examples/broker-features/standard/spring-integration/src/main/resources/broker.xml +++ /dev/null @@ -1,53 +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:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns="urn:activemq" - xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> - - <jms xmlns="urn:activemq:jms"> - <!--the queue used by the example--> - <queue name="exampleQueue"/> - </jms> - - <core xmlns="urn:activemq:core"> - - <persistence-enabled>false</persistence-enabled> - - <acceptors> - <acceptor name="in-vm">vm://0</acceptor> - </acceptors> - - <!-- Other config --> - - <security-settings> - <!--security for example queue--> - <security-setting match="#"> - <permission type="createDurableQueue" roles="guest"/> - <permission type="deleteDurableQueue" roles="guest"/> - <permission type="createNonDurableQueue" roles="guest"/> - <permission type="deleteNonDurableQueue" 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/6b17d966/examples/broker-features/standard/spring-integration/src/main/resources/spring-jms-beans.xml ---------------------------------------------------------------------- diff --git a/examples/broker-features/standard/spring-integration/src/main/resources/spring-jms-beans.xml b/examples/broker-features/standard/spring-integration/src/main/resources/spring-jms-beans.xml deleted file mode 100644 index a67de73..0000000 --- a/examples/broker-features/standard/spring-integration/src/main/resources/spring-jms-beans.xml +++ /dev/null @@ -1,80 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<!-- -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. ---> - -<beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> - - <bean id="securityManager" class="org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManagerImpl"> - <constructor-arg> - <bean class="org.apache.activemq.artemis.core.config.impl.SecurityConfiguration"> - <constructor-arg name="users"> - <map> - <entry key="guest" value="guest"/> - </map> - </constructor-arg> - <constructor-arg name="roles"> - <map> - <entry key="guest"> - <list> - <value>guest</value> - </list> - </entry> - </map> - </constructor-arg> - <property name="DefaultUser" value="guest"/> - </bean> - </constructor-arg> - </bean> - - <bean id="EmbeddedJms" class="org.apache.activemq.artemis.integration.spring.SpringJmsBootstrap" init-method="start" - destroy-method="stop"> - <property name="SecurityManager" ref="securityManager"/> - </bean> - - <bean id="connectionFactory" class="org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory"> - <constructor-arg value="false"/> - <constructor-arg> - <bean class="org.apache.activemq.artemis.api.core.TransportConfiguration"> - <constructor-arg value="org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory"/> - </bean> - </constructor-arg> - </bean> - - <bean id="exampleQueue" class="org.apache.activemq.artemis.jms.client.ActiveMQQueue"> - <constructor-arg index="0" value="exampleQueue"/> - </bean> - - <bean id="listener" class="org.apache.activemq.artemis.jms.example.ExampleListener"/> - - <bean id="MessageSender" class="org.apache.activemq.artemis.jms.example.MessageSender"> - <property name="connectionFactory" ref="connectionFactory"/> - <property name="destination" ref="exampleQueue"/> - </bean> - - <bean id="listenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer"> - <property name="connectionFactory" ref="connectionFactory"/> - <property name="destination" ref="exampleQueue"/> - <property name="messageListener" ref="listener"/> - </bean> -</beans> - http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/ssl-enabled/pom.xml ---------------------------------------------------------------------- diff --git a/examples/broker-features/standard/ssl-enabled/pom.xml b/examples/broker-features/standard/ssl-enabled/pom.xml deleted file mode 100644 index 7a76435..0000000 --- a/examples/broker-features/standard/ssl-enabled/pom.xml +++ /dev/null @@ -1,109 +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>1.0.1-SNAPSHOT</version> - </parent> - - <artifactId>ssl-enabled</artifactId> - <packaging>jar</packaging> - <name>ActiveMQ Artemis JMS SSL Enabled Example</name> - - <properties> - <activemq.basedir>${project.basedir}/../../../..</activemq.basedir> - </properties> - - <dependencies> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-jms-client</artifactId> - <version>${project.version}</version> - </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> - <ignore>${noServer}</ignore> - </configuration> - </execution> - <execution> - <id>start</id> - <goals> - <goal>cli</goal> - </goals> - <configuration> - <ignore>${noServer}</ignore> - <spawn>true</spawn> - <testURI>tcp://localhost:5500?sslEnabled=true&trustStorePath=activemq/server0/activemq.example.truststore&trustStorePassword=activemqexample</testURI> - <args> - <param>run</param> - </args> - </configuration> - </execution> - <execution> - <id>runClient</id> - <goals> - <goal>runClient</goal> - </goals> - <configuration> - <clientClass>org.apache.activemq.artemis.jms.example.SSLExample</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>ssl-enabled</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> - </plugin> - </plugins> - </build> - -</project> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/ssl-enabled/readme.html ---------------------------------------------------------------------- diff --git a/examples/broker-features/standard/ssl-enabled/readme.html b/examples/broker-features/standard/ssl-enabled/readme.html deleted file mode 100644 index bb5e724..0000000 --- a/examples/broker-features/standard/ssl-enabled/readme.html +++ /dev/null @@ -1,56 +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 SSL 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 SSL 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 configure SSL with ActiveMQ Artemis to send and receive message. </p> - - <p>Using SSL can make your messaging applications interact with ActiveMQ Artemis securely. An application can - be secured transparently without extra coding effort. To secure your messaging application with SSL, you need to configure connector and acceptor as follows:</p> - - <p> - <pre class="prettyprint"> - <code> - <!-- Connector --> - - <connector name="netty-ssl-connector">tcp://localhost:5500?sslEnabled=true;keyStorePath=activemq/server0/activemq.example.keystore;keyStorePassword=activemqexample</connector> - - <!-- Acceptor --> - - <acceptor name="netty-ssl-acceptor">tcp://localhost:5500?sslEnabled=true;keyStorePath=activemq/server0/activemq.example.keystore;keyStorePassword=activemqexample</acceptor> - - </code> - </pre> - </p> - - <p>In the configuration, the activemq.example.keystore is the key store file holding the server's certificate. The activemq.example.truststore - is the file holding the certificates which the client trusts (i.e. the server's certificate exported from activemq.example.keystore). They are pre-generated for illustration purpose<a id="fnr1" href="readme.html#fn1"><sup>1</sup></a>.</p> - </body> -</html> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/ssl-enabled/src/main/java/org/apache/activemq/artemis/jms/example/SSLExample.java ---------------------------------------------------------------------- diff --git a/examples/broker-features/standard/ssl-enabled/src/main/java/org/apache/activemq/artemis/jms/example/SSLExample.java b/examples/broker-features/standard/ssl-enabled/src/main/java/org/apache/activemq/artemis/jms/example/SSLExample.java deleted file mode 100644 index 27bf739..0000000 --- a/examples/broker-features/standard/ssl-enabled/src/main/java/org/apache/activemq/artemis/jms/example/SSLExample.java +++ /dev/null @@ -1,86 +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.jms.example; - -import javax.jms.Connection; -import javax.jms.ConnectionFactory; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.Queue; -import javax.jms.Session; -import javax.jms.TextMessage; -import javax.naming.InitialContext; - -/** - * A simple JMS Queue example that uses SSL secure transport. - */ -public class SSLExample { - - public static void main(final String[] args) throws Exception { - Connection connection = null; - InitialContext initialContext = null; - try { - // Step 1. Create an initial context to perform the JNDI lookup. - initialContext = new InitialContext(); - - // Step 2. Perfom a lookup on the queue - Queue queue = (Queue) initialContext.lookup("queue/exampleQueue"); - - // Step 3. Perform a lookup on the Connection Factory - ConnectionFactory cf = (ConnectionFactory) initialContext.lookup("ConnectionFactory"); - - // Step 4.Create a JMS Connection - connection = cf.createConnection(); - - // Step 5. Create a JMS Session - Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - - // Step 6. Create a JMS Message Producer - MessageProducer producer = session.createProducer(queue); - - // Step 7. Create a Text Message - TextMessage message = session.createTextMessage("This is a text message"); - - System.out.println("Sent message: " + message.getText()); - - // Step 8. Send the Message - producer.send(message); - - // Step 9. Create a JMS Message Consumer - MessageConsumer messageConsumer = session.createConsumer(queue); - - // Step 10. Start the Connection - connection.start(); - - // Step 11. Receive the message - TextMessage messageReceived = (TextMessage) messageConsumer.receive(5000); - - System.out.println("Received message: " + messageReceived.getText()); - - initialContext.close(); - } - finally { - // Step 12. Be sure to close our JMS resources! - if (initialContext != null) { - initialContext.close(); - } - if (connection != null) { - connection.close(); - } - } - } -}