Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 71F5E200D81 for ; Fri, 15 Dec 2017 15:55:24 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 70A59160C26; Fri, 15 Dec 2017 14:55:24 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 298CC160C28 for ; Fri, 15 Dec 2017 15:55:22 +0100 (CET) Received: (qmail 35959 invoked by uid 500); 15 Dec 2017 14:55:21 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 35853 invoked by uid 99); 15 Dec 2017 14:55:21 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 15 Dec 2017 14:55:21 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 22991E7DA2; Fri, 15 Dec 2017 14:55:20 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: martyntaylor@apache.org To: commits@activemq.apache.org Date: Fri, 15 Dec 2017 14:55:24 -0000 Message-Id: <6aba585594284f9285d9df9a2859e783@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [05/14] activemq-artemis git commit: ARTEMIS-1562 Refactor example documentation archived-at: Fri, 15 Dec 2017 14:55:24 -0000 http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/rest/jms-to-rest/pom.xml ---------------------------------------------------------------------- diff --git a/examples/features/standard/rest/jms-to-rest/pom.xml b/examples/features/standard/rest/jms-to-rest/pom.xml index be63429..403d021 100644 --- a/examples/features/standard/rest/jms-to-rest/pom.xml +++ b/examples/features/standard/rest/jms-to-rest/pom.xml @@ -33,6 +33,64 @@ under the License. ${project.basedir}/../../../../.. + + + org.apache.activemq + artemis-core-client + ${project.version} + + + org.apache.activemq + artemis-server + ${project.version} + + + org.apache.activemq + artemis-jms-client + ${project.version} + + + org.apache.activemq + artemis-jms-server + ${project.version} + + + io.netty + netty-all + + + org.apache.geronimo.specs + geronimo-jms_2.0_spec + + + org.apache.activemq.rest + artemis-rest + ${project.version} + + + org.jboss.resteasy + resteasy-jaxrs + + + org.jboss.resteasy + resteasy-jaxb-provider + + + junit + junit + test + + + + + + + org.apache.maven.plugins + maven-clean-plugin + + + + example @@ -103,53 +161,16 @@ under the License. + + release + + + + com.vladsch.flexmark + markdown-page-generator-plugin + + + + - - - org.apache.activemq - artemis-core-client - ${project.version} - - - org.apache.activemq - artemis-server - ${project.version} - - - org.apache.activemq - artemis-jms-client - ${project.version} - - - org.apache.activemq - artemis-jms-server - ${project.version} - - - io.netty - netty-all - - - org.apache.geronimo.specs - geronimo-jms_2.0_spec - - - org.apache.activemq.rest - artemis-rest - ${project.version} - - - org.jboss.resteasy - resteasy-jaxrs - - - org.jboss.resteasy - resteasy-jaxb-provider - - - junit - junit - test - - http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/rest/jms-to-rest/readme.md ---------------------------------------------------------------------- diff --git a/examples/features/standard/rest/jms-to-rest/readme.md b/examples/features/standard/rest/jms-to-rest/readme.md new file mode 100644 index 0000000..16a5169 --- /dev/null +++ b/examples/features/standard/rest/jms-to-rest/readme.md @@ -0,0 +1,49 @@ +# Mixed JMS and REST Producers/Consumers Example + +This is an example of mixing JMS producers and consumers with REST producers and consumers. The REST clients have been +written in both Java using RESTEasy's client library and within the Python language. You will need Python 2.6.1 or higher +to be able to run the Python clients. + +To run the example you will need 5 shell-script windows (or you'll need to run 4 processes in background) + +Step 1: + + mvn jetty:run + +This will bring up ActiveMQ Artemis and the ActiveMQ Artemis REST Interface. + +Step 2: + + mvn exec:java -Dexec.mainClass="RestReceive" + +This will bring up a Java REST client that is continuously pulling the broker through a consume-next (see doco for details). + +Step 3: + + mvn exec:java -Dexec.mainClass="JmsReceive" + +This will bring up a Java JMS consumer that is using the MessageListener interface to consume messages. It will +extract a Order instance from the JMS Message it receives. + +Step 4: + + python receiveOrder.py + +This runs a very simple Python program to consume messages + +Step 5: +Use one of these three commands to post messages to the system. One of the receive clients will consume the message. + + mvn exec:java -Dexec.mainClass="JmsSend" + +A JMS client will create an Order object and send it to the queue. You'll see one of the 4 clients receive the message. +Notice that the REST clients automatically cause the Order object to be transformed on the broker and passed as XML +to the REST client. + + mvn exec:java -Dexec.mainClass="RestSend" + +This is a REST client that uses the Acknowledgement protocol to receive a message from the queue. + + python postOrder.py + +This is a Python client that posts one message to the queue RESTfully (of course ;) ) http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/rest/jms-to-rest/src/main/resources/broker.xml ---------------------------------------------------------------------- diff --git a/examples/features/standard/rest/jms-to-rest/src/main/resources/broker.xml b/examples/features/standard/rest/jms-to-rest/src/main/resources/broker.xml index 1628bdb..2624b8b 100644 --- a/examples/features/standard/rest/jms-to-rest/src/main/resources/broker.xml +++ b/examples/features/standard/rest/jms-to-rest/src/main/resources/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. ---> - - - +--> + false false http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/rest/push/README.txt ---------------------------------------------------------------------- diff --git a/examples/features/standard/rest/push/README.txt b/examples/features/standard/rest/push/README.txt deleted file mode 100644 index c5c0f3a..0000000 --- a/examples/features/standard/rest/push/README.txt +++ /dev/null @@ -1,32 +0,0 @@ -System Requirements: -You will need JDK 1.8 and Maven to run this example. This example has been tested with Maven 3.3.3. It may or may not work -with earlier or later versions of Maven. - - -This is an example of having the ActiveMQ Artemis REST interface forward a posted message to a registered URL. - -To run the example you will need 3 shell-script windows (or you'll need to run 2 processes in background) - -Step 1: -$ mvn jetty:run - -This will bring up ActiveMQ Artemis and the ActiveMQ Artemis REST Interface. Two queues will be created. An "order" queue and a "shipping" -queue. The server will forward posted messages to the "shipping" queue through a registered push subscription. - -Step 2: -$ mvn exec:java -Dexec.mainClass="ReceiveShipping" - -This will bring up a JMS client registers a MessageListener consumer to receive Order objects. It will automatically -convert a posted HTTP message into an Order object using JAX-RS content handlers. - -Step 3: -$ mvn exec:java -Dexec.mainClass="PushReg" - -This creates a push registration that listens on the "order" queue and forwards messages posted to it to a URL. This -URL is the REST resource of the "shipping" queue. - -Step 4: - -$ mvn exec:java -Dexec.mainClass="PostOrder" - -This posts an order to the "order" queue. You'll see it eventually consumed by the ReceiveShipping process. http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/rest/push/pom.xml ---------------------------------------------------------------------- diff --git a/examples/features/standard/rest/push/pom.xml b/examples/features/standard/rest/push/pom.xml index 8bc3aba..8b20ce9 100644 --- a/examples/features/standard/rest/push/pom.xml +++ b/examples/features/standard/rest/push/pom.xml @@ -33,12 +33,63 @@ under the License. ${project.basedir}/../../../../.. - - - jboss - http://repository.jboss.org/nexus/content/groups/public/ - - + + + org.apache.activemq + artemis-core-client + ${project.version} + + + org.apache.activemq + artemis-server + ${project.version} + + + org.apache.activemq + artemis-jms-client + ${project.version} + + + org.apache.activemq + artemis-jms-server + ${project.version} + + + io.netty + netty-all + + + org.apache.geronimo.specs + geronimo-jms_2.0_spec + + + org.apache.activemq.rest + artemis-rest + ${project.version} + + + org.jboss.resteasy + resteasy-jaxrs + + + org.jboss.resteasy + resteasy-jaxb-provider + + + junit + junit + test + + + + + + + org.apache.maven.plugins + maven-clean-plugin + + + @@ -110,53 +161,16 @@ under the License. + + release + + + + com.vladsch.flexmark + markdown-page-generator-plugin + + + + - - - org.apache.activemq - artemis-core-client - ${project.version} - - - org.apache.activemq - artemis-server - ${project.version} - - - org.apache.activemq - artemis-jms-client - ${project.version} - - - org.apache.activemq - artemis-jms-server - ${project.version} - - - io.netty - netty-all - - - org.apache.geronimo.specs - geronimo-jms_2.0_spec - - - org.apache.activemq.rest - artemis-rest - ${project.version} - - - org.jboss.resteasy - resteasy-jaxrs - - - org.jboss.resteasy - resteasy-jaxb-provider - - - junit - junit - test - - http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/rest/push/readme.md ---------------------------------------------------------------------- diff --git a/examples/features/standard/rest/push/readme.md b/examples/features/standard/rest/push/readme.md new file mode 100644 index 0000000..99362fe --- /dev/null +++ b/examples/features/standard/rest/push/readme.md @@ -0,0 +1,32 @@ +# Rest Push Subscriptions Example + +This is an example of having the ActiveMQ Artemis REST interface forward a posted message to a registered URL. + +To run the example you will need 3 shell-script windows (or you'll need to run 2 processes in background) + +Step 1: + + mvn jetty:run + +This will bring up ActiveMQ Artemis and the ActiveMQ Artemis REST Interface. Two queues will be created. An "order" queue and a "shipping" +queue. The broker will forward posted messages to the "shipping" queue through a registered push subscription. + +Step 2: + + mvn exec:java -Dexec.mainClass="ReceiveShipping" + +This will bring up a JMS client registers a MessageListener consumer to receive Order objects. It will automatically +convert a posted HTTP message into an Order object using JAX-RS content handlers. + +Step 3: + + mvn exec:java -Dexec.mainClass="PushReg" + +This creates a push registration that listens on the "order" queue and forwards messages posted to it to a URL. This +URL is the REST resource of the "shipping" queue. + +Step 4: + + mvn exec:java -Dexec.mainClass="PostOrder" + +This posts an order to the "order" queue. You'll see it eventually consumed by the ReceiveShipping process. http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/rest/push/src/main/resources/broker.xml ---------------------------------------------------------------------- diff --git a/examples/features/standard/rest/push/src/main/resources/broker.xml b/examples/features/standard/rest/push/src/main/resources/broker.xml index d58574e..aff50d7 100644 --- a/examples/features/standard/rest/push/src/main/resources/broker.xml +++ b/examples/features/standard/rest/push/src/main/resources/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. ---> - - - +--> + false false @@ -28,7 +26,7 @@ under the License. vm://0 tcp://localhost:61616 - +
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/scheduled-message/pom.xml ---------------------------------------------------------------------- diff --git a/examples/features/standard/scheduled-message/pom.xml b/examples/features/standard/scheduled-message/pom.xml index f953c86..96ddc1c 100644 --- a/examples/features/standard/scheduled-message/pom.xml +++ b/examples/features/standard/scheduled-message/pom.xml @@ -107,7 +107,23 @@ under the License. + + org.apache.maven.plugins + maven-clean-plugin + - - + + + release + + + + com.vladsch.flexmark + markdown-page-generator-plugin + + + + + + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/scheduled-message/readme.html ---------------------------------------------------------------------- diff --git a/examples/features/standard/scheduled-message/readme.html b/examples/features/standard/scheduled-message/readme.html deleted file mode 100644 index 9144f94..0000000 --- a/examples/features/standard/scheduled-message/readme.html +++ /dev/null @@ -1,134 +0,0 @@ - - - - - ActiveMQ Artemis Scheduled Message Example - - - - - -

JMS Scheduled Message Example

- -
To run the example, simply type mvn verify from this directory, 
or mvn -PnoServer verify if you want to start and create the server manually.
- - -

This example shows you how to send a scheduled message to a JMS Queue using ActiveMQ Artemis.

-

A Scheduled Message is a message that will be delivered at a time specified by the sender. To do this, - simply set a HDR_SCHEDULED_DELIVERY_TIME header property. The value of the property should be the time of - delivery in milliseconds.

- -

In this example, a message is created with the scheduled delivery time set to 5 seconds after the current time.

- - -

Example step-by-step

-

To run the example, simply type mvn verify -Pexample from this directory

- -
    -
  1. 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 client-jndi.properties file in the directory ../common/config
  2. -
    -           InitialContext initialContext = getContext();
    -        
    - -
  3. We look-up the JMS queue object from JNDI
  4. -
    -           Queue queue = (Queue) initialContext.lookup("/queue/exampleQueue");
    -        
    - -
  5. We look-up the JMS connection factory object from JNDI
  6. -
    -           ConnectionFactory cf = (ConnectionFactory) initialContext.lookup("/ConnectionFactory");
    -        
    - -
  7. We create a JMS connection
  8. -
    -           connection = cf.createConnection();
    -        
    - -
  9. We create a JMS session. The session is created as non transacted and will auto acknowledge messages.
  10. -
    -           Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    -        
    - -
  11. We create a JMS message producer on the session. This will be used to send the messages.
  12. -
    -          MessageProducer producer = session.createProducer(queue);
    -       
    - -
  13. We create a JMS text message that we are going to send.
  14. -
    -           TextMessage message = session.createTextMessage("This is a scheduled message message which will be delivered in 5 sec.");
    -        
    - -
  15. We schedule the delivery time to be 5 sec later.
  16. -
    -           
    -            long time = System.currentTimeMillis();
    -            time += 5000;
    -            message.setLongProperty(MessageImpl.HDR_SCHEDULED_DELIVERY_TIME.toString(), time);
    -           
    -        
    - -
  17. We send message to the queue
  18. -
    -           messageProducer.send(message);
    -        
    - -
  19. We create a JMS Message Consumer to receive the message.
  20. -
    -           MessageConsumer messageConsumer = session.createConsumer(queue);
    -        
    - -
  21. We start the connection. In order for delivery to occur on any consumers or subscribers on a connection, the connection must be started
  22. -
    -           connection.start();
    -        
    - -
  23. We use a blocking receive() to consume the message and see when the message arrives.
  24. -
    -           TextMessage messageReceived = (TextMessage) messageConsumer.receive();
    -        
    - -
  25. And finally, always remember to close your JMS connections and resources after use, in a finally block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects
  26. - -
    -           finally
    -           {
    -              if (initialContext != null)
    -              {
    -                initialContext.close();
    -              }
    -              if (connection != null)
    -              {
    -                 connection.close();
    -              }
    -           }
    -        
    - -
- -

More information

- - - - - http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/scheduled-message/readme.md ---------------------------------------------------------------------- diff --git a/examples/features/standard/scheduled-message/readme.md b/examples/features/standard/scheduled-message/readme.md new file mode 100644 index 0000000..2841aae --- /dev/null +++ b/examples/features/standard/scheduled-message/readme.md @@ -0,0 +1,9 @@ +# JMS Scheduled Message 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 send a scheduled message to a JMS Queue using ActiveMQ Artemis. + +A Scheduled Message is a message that will be delivered at a time specified by the sender. To do this, simply set a `org.apache.activemq.artemis.api.core.Message.HDR_SCHEDULED_DELIVERY_TIME` header property. The value of the property should be the time of delivery in milliseconds. + +In this example, a message is created with the scheduled delivery time set to 5 seconds after the current time. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/security-ldap/pom.xml ---------------------------------------------------------------------- diff --git a/examples/features/standard/security-ldap/pom.xml b/examples/features/standard/security-ldap/pom.xml index 4970bce..d283796 100644 --- a/examples/features/standard/security-ldap/pom.xml +++ b/examples/features/standard/security-ldap/pom.xml @@ -144,7 +144,23 @@ under the License. + + org.apache.maven.plugins + maven-clean-plugin + - - + + + release + + + + com.vladsch.flexmark + markdown-page-generator-plugin + + + + + + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/security-ldap/readme.html ---------------------------------------------------------------------- diff --git a/examples/features/standard/security-ldap/readme.html b/examples/features/standard/security-ldap/readme.html deleted file mode 100644 index 430b319..0000000 --- a/examples/features/standard/security-ldap/readme.html +++ /dev/null @@ -1,361 +0,0 @@ - - - - - ActiveMQ Artemis JMS Security Example - - - - - -

JMS Security LDAP Example

- -
To run the example, simply type mvn verify from this directory, 
or mvn -PnoServer verify if you want to start and create the server manually.
- - -

This example shows how to configure and use security using ActiveMQ Artemis and the Apache DS LDAP server.

- -

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.

- -

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.

- -

For a full description of how to configure security with ActiveMQ Artemis, please consult the user - manual.

- -

This example demonstrates how to configure users/roles in the Apache DS LDAP server, how to configure topics with - proper permissions using wild-card expressions, and how they take effects in a simple program.

- -

Users and roles are configured in Apache DS. The SecurityExample class will start an embedded version of Apache - DS and load the contents of example.ldif which contains the users and passwords for this example.

- -
-     
-         dn: dc=activemq,dc=org
-         dc: activemq
-         objectClass: top
-         objectClass: domain
-
-         dn: uid=bill,dc=activemq,dc=org
-         uid: bill
-         userPassword: activemq
-         objectClass: account
-         objectClass: simpleSecurityObject
-         objectClass: top
-
-         dn: uid=andrew,dc=activemq,dc=org
-         uid: andrew
-         userPassword: activemq1
-         objectClass: account
-         objectClass: simpleSecurityObject
-         objectClass: top
-
-         dn: uid=frank,dc=activemq,dc=org
-         uid: frank
-         userPassword: activemq2
-         objectClass: account
-         objectClass: simpleSecurityObject
-         objectClass: top
-
-         dn: uid=sam,dc=activemq,dc=org
-         uid: sam
-         userPassword: activemq3
-         objectClass: account
-         objectClass: simpleSecurityObject
-         objectClass: top
-
-         ###################
-         ## Define roles ##
-         ###################
-
-         dn: cn=user,dc=activemq,dc=org
-         cn: user
-         member: uid=bill,dc=activemq,dc=org
-         member: uid=andrew,dc=activemq,dc=org
-         member: uid=frank,dc=activemq,dc=org
-         member: uid=sam,dc=activemq,dc=org
-         objectClass: groupOfNames
-         objectClass: top
-
-         dn: cn=europe-user,dc=activemq,dc=org
-         cn: europe-user
-         member: uid=andrew,dc=activemq,dc=org
-         objectClass: groupOfNames
-         objectClass: top
-
-         dn: cn=news-user,dc=activemq,dc=org
-         cn: news-user
-         member: uid=frank,dc=activemq,dc=org
-         member: uid=sam,dc=activemq,dc=org
-         objectClass: groupOfNames
-         objectClass: top
-
-         dn: cn=us-user,dc=activemq,dc=org
-         cn: us-user
-         member: uid=frank,dc=activemq,dc=org
-         objectClass: groupOfNames
-         objectClass: top
-     
-     
- -

- 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 broker.xml, like the following -

-

-      <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>
-     
- -

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.

- -

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:

- -
  • Only role 'us-user' can create/delete and pulish messages to topics whose names match wild-card pattern 'news.us.#'.
  • -
  • Only role 'europe-user' can create/delete and publish messages to topics whose names match wild-card pattern 'news.europe.#'.
  • -
  • Only role 'news-user' can subscribe messages to topics whose names match wild-card pattern 'news.us.#' and 'news.europe.#'.
  • -
  • For any other topics that don't match any of the above wild-card patterns, permissions are granted to users of role 'user'.
  • - -

    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.#'.

    - -

    Example step-by-step

    -

    To run the example, simply type mvn verify from this directory

    - -
      -
    1. 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 client-jndi.properties file in the directory ../common/config
    2. -
      -           
      -           InitialContext initialContext = getContext(0);
      -           
      -        
      - -
    3. We perform lookup on the topics
    4. -
      -           
      -           Topic genericTopic = (Topic) initialContext.lookup("/topic/genericTopic");
      -           Topic europeTopic = (Topic) initialContext.lookup("/topic/europeTopic");
      -           Topic usTopic = (Topic) initialContext.lookup("/topic/usTopic");
      -           
      -        
      - -
    5. We perform a lookup on the Connection Factory
    6. -
      -           
      -           ConnectionFactory cf = (ConnectionFactory) initialContext.lookup("/ConnectionFactory");
      -           
      -        
      - -
    7. We try to create a JMS Connection without user/password. It will fail.
    8. -
      -           
      -           try
      -           {
      -              cf.createConnection();
      -              result = false;
      -           }
      -           catch (JMSSecurityException e)
      -           {
      -              System.out.println("Default user cannot get a connection. Details: " + e.getMessage());
      -           }
      -           
      -        
      - -
    9. Bill tries to make a connection using wrong password
    10. -
      -           
      -           billConnection = null;
      -           try
      -           {
      -              billConnection = createConnection("bill", "activemq1", cf);
      -              result = false;
      -           }
      -           catch (JMSException e)
      -           {
      -              System.out.println("User bill failed to connect. Details: " + e.getMessage());
      -           }
      -           
      -        
      - -
    11. Bill makes a good connection.
    12. -
      -          
      -           billConnection = createConnection("bill", "activemq", cf);
      -           billConnection.start();
      -          
      -       
      - -
    13. Andrew makes a good connection
    14. -
      -           
      -           andrewConnection = createConnection("andrew", "activemq1", cf);
      -           andrewConnection.start();
      -           
      -         
      - -
    15. Frank makes a good connection
    16. -
      -           
      -           frankConnection = createConnection("frank", "activemq2", cf);
      -           frankConnection.start();
      -           
      -        
      - -
    17. Sam makes a good connection
    18. -
      -           
      -           samConnection = createConnection("sam", "activemq3", cf);
      -           samConnection.start();
      -           
      -        
      - -
    19. We check every user can publish/subscribe genericTopics
    20. -
      -           
      -           checkUserSendAndReceive(genericTopic, billConnection, "bill");
      -           checkUserSendAndReceive(genericTopic, andrewConnection, "andrew");
      -           checkUserSendAndReceive(genericTopic, frankConnection, "frank");
      -           checkUserSendAndReceive(genericTopic, samConnection, "sam");
      -           
      -        
      - -
    21. We check permissions on news.europe.europeTopic for bill: can't send and can't receive
    22. -
      -           
      -           checkUserNoSendNoReceive(europeTopic, billConnection, "bill", andrewConnection, frankConnection);
      -           
      -        
      - -
    23. We check permissions on news.europe.europeTopic for andrew: can send but can't receive
    24. -
      -           
      -           checkUserSendNoReceive(europeTopic, andrewConnection, "andrew", frankConnection);
      -           
      -        
      - -
    25. We check permissions on news.europe.europeTopic for frank: can't send but can receive
    26. -
      -           
      -           checkUserReceiveNoSend(europeTopic, frankConnection, "frank", andrewConnection);
      -           
      -        
      - -
    27. We check permissions on news.europe.europeTopic for sam: can't send but can receive
    28. -
      -           
      -           checkUserReceiveNoSend(europeTopic, samConnection, "sam", andrewConnection);
      -           
      -        
      - -
    29. We check permissions on news.us.usTopic for bill: can't send and can't receive
    30. -
      -           
      -           checkUserNoSendNoReceive(usTopic, billConnection, "bill");
      -           
      -        
      - -
    31. We check permissions on news.us.usTopic for andrew: can't send and can't receive
    32. -
      -           
      -           checkUserNoSendNoReceive(usTopic, andrewConnection, "andrew");
      -           
      -        
      - -
    33. We check permissions on news.us.usTopic for frank: can both send and receive
    34. -
      -           
      -           checkUserSendAndReceive(usTopic, frankConnection, "frank");
      -           
      -        
      - -
    35. We check permissions on news.us.usTopic for sam: can't send but can receive
    36. -
      -           
      -           checkUserReceiveNoSend(usTopic, samConnection, "sam", frankConnection);
      -           
      -        
      - -
    37. And finally, always remember to close your JMS connections and resources after use, in a finally block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects
    38. - -
      -           
      -           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();
      -              }
      -           }
      -           
      -        
      -
    - - http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/security-ldap/readme.md ---------------------------------------------------------------------- diff --git a/examples/features/standard/security-ldap/readme.md b/examples/features/standard/security-ldap/readme.md new file mode 100644 index 0000000..d966ec4 --- /dev/null +++ b/examples/features/standard/security-ldap/readme.md @@ -0,0 +1,121 @@ +# JMS Security LDAP 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 how to configure and use security using ActiveMQ Artemis and the Apache DS LDAP server. + +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. + +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. + +For a full description of how to configure security with ActiveMQ Artemis, please consult the user manual. + +This example demonstrates how to configure users/roles in the Apache DS LDAP server, how to configure topics with proper permissions using wild-card expressions, and how they take effects in a simple program. + +Users and roles are configured in Apache DS. The SecurityExample class will start an embedded version of Apache DS and load the contents of example.ldif which contains the users and passwords for this example. + + dn: dc=activemq,dc=org + dc: activemq + objectClass: top + objectClass: domain + + dn: uid=bill,dc=activemq,dc=org + uid: bill + userPassword: activemq + objectClass: account + objectClass: simpleSecurityObject + objectClass: top + + dn: uid=andrew,dc=activemq,dc=org + uid: andrew + userPassword: activemq1 + objectClass: account + objectClass: simpleSecurityObject + objectClass: top + + dn: uid=frank,dc=activemq,dc=org + uid: frank + userPassword: activemq2 + objectClass: account + objectClass: simpleSecurityObject + objectClass: top + + dn: uid=sam,dc=activemq,dc=org + uid: sam + userPassword: activemq3 + objectClass: account + objectClass: simpleSecurityObject + objectClass: top + + ################### + ## Define roles ## + ################### + + dn: cn=user,dc=activemq,dc=org + cn: user + member: uid=bill,dc=activemq,dc=org + member: uid=andrew,dc=activemq,dc=org + member: uid=frank,dc=activemq,dc=org + member: uid=sam,dc=activemq,dc=org + objectClass: groupOfNames + objectClass: top + + dn: cn=europe-user,dc=activemq,dc=org + cn: europe-user + member: uid=andrew,dc=activemq,dc=org + objectClass: groupOfNames + objectClass: top + + dn: cn=news-user,dc=activemq,dc=org + cn: news-user + member: uid=frank,dc=activemq,dc=org + member: uid=sam,dc=activemq,dc=org + objectClass: groupOfNames + objectClass: top + + dn: cn=us-user,dc=activemq,dc=org + cn: us-user + member: uid=frank,dc=activemq,dc=org + objectClass: groupOfNames + objectClass: top` + +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 `broker.xml`, like the following + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +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. + +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: + +* Only role `us-user` can create/delete and pulish messages to topics whose names match wild-card pattern `news.us.#`. +* Only role `europe-user` can create/delete and publish messages to topics whose names match wild-card pattern `news.europe.#`. +* Only role `news-user` can subscribe messages to topics whose names match wild-card pattern `news.us.#` and `news.europe.#`. +* For any other topics that don't match any of the above wild-card patterns, permissions are granted to users of role `user`. + +To illustrate the effect of permissions, three topics are deployed. Topic `genericTopic` matches `#` wild-card, topic `news.europe.europeTopic` matches `news.europe.#` wild-cards, and topic `news.us.usTopic` matches `news.us.#`. http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/security-ldap/src/main/resources/activemq/server0/broker.xml ---------------------------------------------------------------------- diff --git a/examples/features/standard/security-ldap/src/main/resources/activemq/server0/broker.xml b/examples/features/standard/security-ldap/src/main/resources/activemq/server0/broker.xml index 6f230a9..c9587ec 100644 --- a/examples/features/standard/security-ldap/src/main/resources/activemq/server0/broker.xml +++ b/examples/features/standard/security-ldap/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. ---> - - - +--> + ./data/messaging/bindings @@ -70,7 +68,7 @@ under the License. - +
    http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/security/pom.xml ---------------------------------------------------------------------- diff --git a/examples/features/standard/security/pom.xml b/examples/features/standard/security/pom.xml index cd8af45..56074af 100644 --- a/examples/features/standard/security/pom.xml +++ b/examples/features/standard/security/pom.xml @@ -105,7 +105,23 @@ under the License. + + org.apache.maven.plugins + maven-clean-plugin + - - + + + release + + + + com.vladsch.flexmark + markdown-page-generator-plugin + + + + + + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/security/readme.html ---------------------------------------------------------------------- diff --git a/examples/features/standard/security/readme.html b/examples/features/standard/security/readme.html deleted file mode 100644 index 749ed79..0000000 --- a/examples/features/standard/security/readme.html +++ /dev/null @@ -1,315 +0,0 @@ - - - - - ActiveMQ Artemis JMS Security Example - - - - - -

    JMS Security Example

    - -
    To run the example, simply type mvn verify from this directory, 
    or mvn -PnoServer verify if you want to start and create the server manually.
    - - -

    This example shows how to configure and use security using ActiveMQ Artemis.

    - -

    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.

    - -

    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.

    - -

    For a full description of how to configure security with ActiveMQ Artemis, please consult the user - manual.

    - -

    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.

    - -

    First we need to configure users with roles. For this example, users and roles are configured in artemis-users.properties - and artemis-roles.properties. The artemis-users.properties file follows the syntax of - <user>=<password>. This example has four users configured as below

    - -
    -     
    -         bill=activemq
    -         andrew=activemq1
    -         frank=activemq2
    -         sam=activemq3
    -     
    -     
    - -

    The artemis-roles.properties file follows the syntax of <role>=<users> where <users> can be - a comma-separated list of users from artemis-users.properties (since more than one user can belong in a - particular role). This example has four roles configured as below

    - -
    -     
    -         user=bill,andrew,frank,sam
    -         europe-user=andrew
    -         news-user=frank,sam
    -         us-user=frank
    -     
    -     
    - -

    - 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 broker.xml, like the following -

    -
    
    -      <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>
    -     
    - -

    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.

    - -

    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:

    - -
  • Only role 'us-user' can create/delete and pulish messages to topics whose names match wild-card pattern 'news.us.#'.
  • -
  • Only role 'europe-user' can create/delete and publish messages to topics whose names match wild-card pattern 'news.europe.#'.
  • -
  • Only role 'news-user' can subscribe messages to topics whose names match wild-card pattern 'news.us.#' and 'news.europe.#'.
  • -
  • For any other topics that don't match any of the above wild-card patterns, permissions are granted to users of role 'user'.
  • - -

    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.#'.

    - -

    Example step-by-step

    -

    To run the example, simply type mvn verify from this directory

    - -
      -
    1. 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 client-jndi.properties file in the directory ../common/config
    2. -
      -           
      -           InitialContext initialContext = getContext(0);
      -           
      -        
      - -
    3. We perform lookup on the topics
    4. -
      -           
      -           Topic genericTopic = (Topic) initialContext.lookup("/topic/genericTopic");
      -           Topic europeTopic = (Topic) initialContext.lookup("/topic/europeTopic");
      -           Topic usTopic = (Topic) initialContext.lookup("/topic/usTopic");
      -           
      -        
      - -
    5. We perform a lookup on the Connection Factory
    6. -
      -           
      -           ConnectionFactory cf = (ConnectionFactory) initialContext.lookup("/ConnectionFactory");
      -           
      -        
      - -
    7. We try to create a JMS Connection without user/password. It will fail.
    8. -
      -           
      -           try
      -           {
      -              cf.createConnection();
      -              result = false;
      -           }
      -           catch (JMSSecurityException e)
      -           {
      -              System.out.println("Default user cannot get a connection. Details: " + e.getMessage());
      -           }
      -           
      -        
      - -
    9. Bill tries to make a connection using wrong password
    10. -
      -           
      -           billConnection = null;
      -           try
      -           {
      -              billConnection = createConnection("bill", "activemq1", cf);
      -              result = false;
      -           }
      -           catch (JMSException e)
      -           {
      -              System.out.println("User bill failed to connect. Details: " + e.getMessage());
      -           }
      -           
      -        
      - -
    11. Bill makes a good connection.
    12. -
      -          
      -           billConnection = createConnection("bill", "activemq", cf);
      -           billConnection.start();
      -          
      -       
      - -
    13. Andrew makes a good connection
    14. -
      -           
      -           andrewConnection = createConnection("andrew", "activemq1", cf);
      -           andrewConnection.start();
      -           
      -         
      - -
    15. Frank makes a good connection
    16. -
      -           
      -           frankConnection = createConnection("frank", "activemq2", cf);
      -           frankConnection.start();
      -           
      -        
      - -
    17. Sam makes a good connection
    18. -
      -           
      -           samConnection = createConnection("sam", "activemq3", cf);
      -           samConnection.start();
      -           
      -        
      - -
    19. We check every user can publish/subscribe genericTopics
    20. -
      -           
      -           checkUserSendAndReceive(genericTopic, billConnection, "bill");
      -           checkUserSendAndReceive(genericTopic, andrewConnection, "andrew");
      -           checkUserSendAndReceive(genericTopic, frankConnection, "frank");
      -           checkUserSendAndReceive(genericTopic, samConnection, "sam");
      -           
      -        
      - -
    21. We check permissions on news.europe.europeTopic for bill: can't send and can't receive
    22. -
      -           
      -           checkUserNoSendNoReceive(europeTopic, billConnection, "bill", andrewConnection, frankConnection);
      -           
      -        
      - -
    23. We check permissions on news.europe.europeTopic for andrew: can send but can't receive
    24. -
      -           
      -           checkUserSendNoReceive(europeTopic, andrewConnection, "andrew", frankConnection);
      -           
      -        
      - -
    25. We check permissions on news.europe.europeTopic for frank: can't send but can receive
    26. -
      -           
      -           checkUserReceiveNoSend(europeTopic, frankConnection, "frank", andrewConnection);
      -           
      -        
      - -
    27. We check permissions on news.europe.europeTopic for sam: can't send but can receive
    28. -
      -           
      -           checkUserReceiveNoSend(europeTopic, samConnection, "sam", andrewConnection);
      -           
      -        
      - -
    29. We check permissions on news.us.usTopic for bill: can't send and can't receive
    30. -
      -           
      -           checkUserNoSendNoReceive(usTopic, billConnection, "bill");
      -           
      -        
      - -
    31. We check permissions on news.us.usTopic for andrew: can't send and can't receive
    32. -
      -           
      -           checkUserNoSendNoReceive(usTopic, andrewConnection, "andrew");
      -           
      -        
      - -
    33. We check permissions on news.us.usTopic for frank: can both send and receive
    34. -
      -           
      -           checkUserSendAndReceive(usTopic, frankConnection, "frank");
      -           
      -        
      - -
    35. We check permissions on news.us.usTopic for sam: can't send but can receive
    36. -
      -           
      -           checkUserReceiveNoSend(usTopic, samConnection, "sam", frankConnection);
      -           
      -        
      - -
    37. And finally, always remember to close your JMS connections and resources after use, in a finally block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects
    38. - -
      -           
      -           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();
      -              }
      -           }
      -           
      -        
      -
    - - http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/security/readme.md ---------------------------------------------------------------------- diff --git a/examples/features/standard/security/readme.md b/examples/features/standard/security/readme.md new file mode 100644 index 0000000..f78df6a --- /dev/null +++ b/examples/features/standard/security/readme.md @@ -0,0 +1,68 @@ +# JMS Security 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 how to configure and use security using ActiveMQ Artemis. + +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. + +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. + +For a full description of how to configure security with ActiveMQ Artemis, please consult the user manual. + +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. + +First we need to configure users with roles. For this example, users and roles are configured in `artemis-users.properties` and `artemis-roles.properties`. The `artemis-users.properties` file follows the syntax of =. This example has four users configured as below + + bill=activemq + andrew=activemq1 + frank=activemq2 + sam=activemq3 + +The `artemis-roles.properties` file follows the syntax of = where can be a comma-separated list of users from `artemis-users.properties` (since more than one user can belong in a particular role). This example has four roles configured as below + + user=bill,andrew,frank,sam + europe-user=andrew + news-user=frank,sam + us-user=frank + +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 `broker.xml`, like the following + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +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. + +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: + +* Only role `us-user` can create/delete and pulish messages to topics whose names match wild-card pattern `news.us.#`. +* Only role `europe-user` can create/delete and publish messages to topics whose names match wild-card pattern `news.europe.#`. +* Only role `news-user` can subscribe messages to topics whose names match wild-card pattern `news.us.#` and `news.europe.#`. +* For any other topics that don't match any of the above wild-card patterns, permissions are granted to users of role `user`. + +To illustrate the effect of permissions, three topics are deployed. Topic `genericTopic` matches `#` wild-card, topic `news.europe.europeTopic` matches `news.europe.#` wild-cards, and topic `news.us.usTopic` matches `news.us.#`. http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/security/src/main/resources/activemq/server0/broker.xml ---------------------------------------------------------------------- diff --git a/examples/features/standard/security/src/main/resources/activemq/server0/broker.xml b/examples/features/standard/security/src/main/resources/activemq/server0/broker.xml index 8e27293..6c2c505 100644 --- a/examples/features/standard/security/src/main/resources/activemq/server0/broker.xml +++ b/examples/features/standard/security/src/main/resources/activemq/server0/broker.xml @@ -17,8 +17,7 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> - - + ./data/messaging/bindings @@ -66,7 +65,7 @@ under the License. - +
    http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/send-acknowledgements/pom.xml ---------------------------------------------------------------------- diff --git a/examples/features/standard/send-acknowledgements/pom.xml b/examples/features/standard/send-acknowledgements/pom.xml index 05a8ae5..12b52ab 100644 --- a/examples/features/standard/send-acknowledgements/pom.xml +++ b/examples/features/standard/send-acknowledgements/pom.xml @@ -97,7 +97,23 @@ under the License. + + org.apache.maven.plugins + maven-clean-plugin + - - + + + release + + + + com.vladsch.flexmark + markdown-page-generator-plugin + + + + + + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/send-acknowledgements/readme.html ---------------------------------------------------------------------- diff --git a/examples/features/standard/send-acknowledgements/readme.html b/examples/features/standard/send-acknowledgements/readme.html deleted file mode 100644 index fcc37fc..0000000 --- a/examples/features/standard/send-acknowledgements/readme.html +++ /dev/null @@ -1,140 +0,0 @@ - - - - - ActiveMQ Artemis Asynchronous Send Acknowledgements Example - - - - - -

    Asynchronous Send Acknowledgements Example

    - -
    To run the example, simply type mvn verify from this directory, 
    or mvn -PnoServer verify if you want to start and create the server manually.
    - - -

    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

    -

    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. - -

    For more information on Asynchronous Send Acknowledgements please see the user manual

    -

    Example step-by-step

    -

    To run the example, simply type mvn verify -Pexample from this directory

    - -
      -
    1. 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 client-jndi.properties file in the directory ../common/config
    2. -
      -           InitialContext initialContext = getContext();
      -        
      - -
    3. We look-up the JMS queue object from JNDI
    4. -
      -           Queue queue = (Queue) initialContext.lookup("/queue/exampleQueue");
      -        
      - -
    5. We look-up the JMS connection factory object from JNDI
    6. -
      -           ConnectionFactory cf = (ConnectionFactory) initialContext.lookup("/ConnectionFactory");
      -        
      - -
    7. We create a JMS connection
    8. -
      -           connection = cf.createConnection();
      -        
      - -
    9. Define a SendAcknowledgementHandler which will receive asynchronous acknowledgements
    10. -
      -           
      -         class MySendAcknowledgementsHandler implements SendAcknowledgementHandler
      -         {
      -            int count = 0;
      -
      -            public void sendAcknowledged(final Message message)
      -            {
      -               System.out.println("Received send acknowledgement for message " + count++);
      -            }
      -         }
      -           
      -        
      - -
    11. Create a JMS session
    12. -
      -          Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
      -       
      - -
    13. Set the handler on the underlying core session
    14. -
      -           
      -         ClientSession coreSession = ((ActiveMQSession)session).getCoreSession();
      -
      -         coreSession.setSendAcknowledgementHandler(new MySendAcknowledgementsHandler());
      -
      -           
      -        
      - -
    15. Create a JMS Message Producer
    16. -
      -           
      -         MessageProducer producer = session.createProducer(queue);
      -
      -         producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
      -           
      -        
      - -
    17. Send 5000 messages, the handler will get called asynchronously some time later after the messages are sent.
    18. -
      -           
      -         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);
      -         }
      -           
      -        
      - - -
    19. And finally, always remember to close your JMS connections and resources after use, in a finally block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects
    20. - -
      -           finally
      -           {
      -              if (initialContext != null)
      -              {
      -                initialContext.close();
      -              }
      -              if (connection != null)
      -              {
      -                 connection.close();
      -              }
      -           }
      -        
      - - - -
    - - http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/send-acknowledgements/readme.md ---------------------------------------------------------------------- diff --git a/examples/features/standard/send-acknowledgements/readme.md b/examples/features/standard/send-acknowledgements/readme.md new file mode 100644 index 0000000..e9dc702 --- /dev/null +++ b/examples/features/standard/send-acknowledgements/readme.md @@ -0,0 +1,9 @@ +# Asynchronous Send Acknowledgements 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. + +Asynchronous Send Acknowledgements are an advanced feature of ActiveMQ Artemis which allow you to receive acknowledgements that messages were successfully received at the broker in a separate thread to the sending thread + +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 broker without blocking and asynchronously receive send acknowledgements via the SendAcknowledgementHandler. + +For more information on Asynchronous Send Acknowledgements please see the user manual \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/send-acknowledgements/src/main/java/org/apache/activemq/artemis/jms/example/SendAcknowledgementsExample.java ---------------------------------------------------------------------- diff --git a/examples/features/standard/send-acknowledgements/src/main/java/org/apache/activemq/artemis/jms/example/SendAcknowledgementsExample.java b/examples/features/standard/send-acknowledgements/src/main/java/org/apache/activemq/artemis/jms/example/SendAcknowledgementsExample.java index a3097d2..e816ddc 100644 --- a/examples/features/standard/send-acknowledgements/src/main/java/org/apache/activemq/artemis/jms/example/SendAcknowledgementsExample.java +++ b/examples/features/standard/send-acknowledgements/src/main/java/org/apache/activemq/artemis/jms/example/SendAcknowledgementsExample.java @@ -33,7 +33,7 @@ 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 + * For more information please see the readme file */ public class SendAcknowledgementsExample { http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/spring-integration/pom.xml ---------------------------------------------------------------------- diff --git a/examples/features/standard/spring-integration/pom.xml b/examples/features/standard/spring-integration/pom.xml index 6373b2b..ed1b997 100644 --- a/examples/features/standard/spring-integration/pom.xml +++ b/examples/features/standard/spring-integration/pom.xml @@ -79,7 +79,23 @@ under the License. + + org.apache.maven.plugins + maven-clean-plugin + - - + + + release + + + + com.vladsch.flexmark + markdown-page-generator-plugin + + + + + + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/spring-integration/readme.html ---------------------------------------------------------------------- diff --git a/examples/features/standard/spring-integration/readme.html b/examples/features/standard/spring-integration/readme.html deleted file mode 100644 index a3855d0..0000000 --- a/examples/features/standard/spring-integration/readme.html +++ /dev/null @@ -1,36 +0,0 @@ - - - - - ActiveMQ Artemis Spring Example - - - - - -

    ActiveMQ Artemis Spring Example

    - -

    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.

    - -

    Example step-by-step

    -

    YOU MUST DOWNLOAD THE SPRING LIBRARIES TO RUN THIS EXAMPLE!!! You must also modify the build.xml file to include the spring jars. You'll see the placeholder that is already there.

    -

    To run the example, simply type mvn verify -Pexample from this directory

    - - http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/spring-integration/readme.md ---------------------------------------------------------------------- diff --git a/examples/features/standard/spring-integration/readme.md b/examples/features/standard/spring-integration/readme.md new file mode 100644 index 0000000..41c2c9e --- /dev/null +++ b/examples/features/standard/spring-integration/readme.md @@ -0,0 +1,5 @@ +# ActiveMQ Artemis Spring Example + +To run the example, simply type **mvn verify -Pexample** from this directory + +This examples shows how to setup and run an embedded broker within a Spring ApplicationContext using ActiveMQ Artemis along with ActiveMQ Artemis configuration files. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b77cdaf7/examples/features/standard/spring-integration/src/main/resources/broker.xml ---------------------------------------------------------------------- diff --git a/examples/features/standard/spring-integration/src/main/resources/broker.xml b/examples/features/standard/spring-integration/src/main/resources/broker.xml index 8ad3a41..9d703b3 100644 --- a/examples/features/standard/spring-integration/src/main/resources/broker.xml +++ b/examples/features/standard/spring-integration/src/main/resources/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. ---> - - - +--> + false @@ -42,7 +40,7 @@ under the License. - +