You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2015/03/12 00:15:57 UTC

[1/5] activemq-6 git commit: Fix jms/embedded-simple example

Repository: activemq-6
Updated Branches:
  refs/heads/master dba926a1c -> 670f5841b


Fix jms/embedded-simple example


Project: http://git-wip-us.apache.org/repos/asf/activemq-6/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-6/commit/4b7eafdd
Tree: http://git-wip-us.apache.org/repos/asf/activemq-6/tree/4b7eafdd
Diff: http://git-wip-us.apache.org/repos/asf/activemq-6/diff/4b7eafdd

Branch: refs/heads/master
Commit: 4b7eafddc1cbaf87eb7eb06919bd1d928042e339
Parents: dba926a
Author: Howard Gao <hg...@redhat.com>
Authored: Tue Mar 10 21:28:07 2015 +0800
Committer: Howard Gao <hg...@redhat.com>
Committed: Wed Mar 11 16:50:52 2015 +0800

----------------------------------------------------------------------
 examples/jms/embedded-simple/readme.html        | 53 ++++++++++++++------
 .../activemq/jms/example/EmbeddedExample.java   | 11 ++++
 .../main/resources/activemq-configuration.xml   |  9 ++--
 .../main/resources/activemq-roles.properties    | 17 -------
 .../main/resources/activemq-users.properties    | 17 -------
 5 files changed, 54 insertions(+), 53 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-6/blob/4b7eafdd/examples/jms/embedded-simple/readme.html
----------------------------------------------------------------------
diff --git a/examples/jms/embedded-simple/readme.html b/examples/jms/embedded-simple/readme.html
index 7a4104c..bf41258 100644
--- a/examples/jms/embedded-simple/readme.html
+++ b/examples/jms/embedded-simple/readme.html
@@ -34,38 +34,63 @@ under the License.
 
       <ol>
          <li>Create ActiveMQ core configuration files and make sure they are within your classpath.  By default, ActiveMQ
-             expects the classnames to be "activemq-configuration.xml", "activemq-jms.xml", and "activemq-users.xml".</li>
-         <li>Create and start ActiveMQ JMS server</li>
+             expects the configuration file name to be "activemq-configuration.xml".</li>
+         <li>Create an embedded ActiveMQ JMS server</li>
          <pre class="prettyprint">
-            <code>EmbeddedJMS jmsServer = new EmbeddedJMS();
-            jmsServer.start();</code>
+            <code>EmbeddedJMS jmsServer = new EmbeddedJMS();</code>
          </pre>
-        
+
+         <li>Setup security configurations</li>
+         <pre class="prettyprint">
+            <code>SecurityConfiguration securityConfig = new SecurityConfiguration();
+            securityConfig.addUser("guest", "guest");
+            securityConfig.addRole("guest", "guest");
+            securityConfig.setDefaultUser("guest");
+            jmsServer.setSecurityManager(new ActiveMQSecurityManagerImpl(securityConfig));</code>
+         </pre>
+
+         <li>Start the embedded ActiveMQ JMS server</li>
+         <pre class="prettyprint">
+            <code>jmsServer.start()</code>
+         </pre>
+
+         <li>Create JMS resources (connection factory and queue) for the example</li>
+         <pre class="prettyprint">
+            <code>JMSServerManager jmsServerManager = jmsServer.getJMSServerManager();
+            List<String> connectors = new ArrayList<String>();
+            connectors.add("in-vm");
+            jmsServerManager.createConnectionFactory("ConnectionFactory", false, JMSFactoryType.CF, connectors, "ConnectionFactory");
+            jmsServerManager.createQueue(false, "exampleQueue", null, false, "queue/exampleQueue");</code>
+         </pre>
+
          <p>At this point the JMS server is started and any JMS clients can look up JMS resources from the JNDI to send/receive 
             messages from the server. To keep the example simple, we will send and receive a JMS message from the same JVM 
             used to run the JMS server.</p>
               
          <li>Lookup JMS resources defined in the configuration </li>
          <pre class="prettyprint">
-            <code>ConnectionFactory cf = (ConnectionFactory)context.lookup("/cf");
-            Queue queue = (Queue)context.lookup("/queue/queue1");</code>
+            <code>ConnectionFactory cf = (ConnectionFactory)jmsServer.lookup("ConnectionFactory");
+            Queue queue = (Queue)jmsServer.lookup("queue/exampleQueue");</code>
          </pre>
          
          <li>Send and receive a message using JMS API</li>
-         <p>See the <a href="../../queue/readme.html">Queue Example</a> for detailed steps to send and receive a JMS message</p>
+         <p>See the <a href="../queue/readme.html">Queue Example</a> for detailed steps to send and receive a JMS message</p>
            
          <p>Finally, we stop the JMS server and its associated resources.</p>
-        
+
+         <li>Close the connection</li>
+         <pre class="prettyprint">
+            <code>if (connection != null)
+            {
+               connection.close();
+            }</code>
+         </pre>
+
          <li>Stop the JMS server</li>
          <pre class="prettyprint">
             <code>jmsServer.stop();</code>
          </pre>
         
-         <li>Stop the JNDI server</li>
-         <pre class="prettyprint">
-            <code>naming.stop();
-            jndiServer.stop();</code>
-         </pre>
       </ol>
    </body>
 </html>

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/4b7eafdd/examples/jms/embedded-simple/src/main/java/org/apache/activemq/jms/example/EmbeddedExample.java
----------------------------------------------------------------------
diff --git a/examples/jms/embedded-simple/src/main/java/org/apache/activemq/jms/example/EmbeddedExample.java b/examples/jms/embedded-simple/src/main/java/org/apache/activemq/jms/example/EmbeddedExample.java
index 008a604..838c3fd 100644
--- a/examples/jms/embedded-simple/src/main/java/org/apache/activemq/jms/example/EmbeddedExample.java
+++ b/examples/jms/embedded-simple/src/main/java/org/apache/activemq/jms/example/EmbeddedExample.java
@@ -29,8 +29,10 @@ import javax.jms.Session;
 import javax.jms.TextMessage;
 
 import org.apache.activemq.common.example.ActiveMQExample;
+import org.apache.activemq.core.config.impl.SecurityConfiguration;
 import org.apache.activemq.jms.server.embedded.EmbeddedJMS;
 import org.apache.activemq.jms.server.JMSServerManager;
+import org.apache.activemq.spi.core.security.ActiveMQSecurityManagerImpl;
 import org.apache.activemq.api.jms.JMSFactoryType;
 
 /**
@@ -50,6 +52,13 @@ public class EmbeddedExample extends ActiveMQExample
       try
       {
          EmbeddedJMS jmsServer = new EmbeddedJMS();
+
+         SecurityConfiguration securityConfig = new SecurityConfiguration();
+         securityConfig.addUser("guest", "guest");
+         securityConfig.addRole("guest", "guest");
+         securityConfig.setDefaultUser("guest");
+         jmsServer.setSecurityManager(new ActiveMQSecurityManagerImpl(securityConfig));
+
          jmsServer.start();
          System.out.println("Started Embedded JMS Server");
 
@@ -57,6 +66,8 @@ public class EmbeddedExample extends ActiveMQExample
          List<String> connectors = new ArrayList<String>();
          connectors.add("in-vm");
          jmsServerManager.createConnectionFactory("ConnectionFactory", false, JMSFactoryType.CF, connectors, "ConnectionFactory");
+         jmsServerManager.createQueue(false, "exampleQueue", null, false, "queue/exampleQueue");
+
          ConnectionFactory cf = (ConnectionFactory)jmsServer.lookup("ConnectionFactory");
          Queue queue = (Queue)jmsServer.lookup("queue/exampleQueue");
 

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/4b7eafdd/examples/jms/embedded-simple/src/main/resources/activemq-configuration.xml
----------------------------------------------------------------------
diff --git a/examples/jms/embedded-simple/src/main/resources/activemq-configuration.xml b/examples/jms/embedded-simple/src/main/resources/activemq-configuration.xml
index fdc8811..68cca46 100644
--- a/examples/jms/embedded-simple/src/main/resources/activemq-configuration.xml
+++ b/examples/jms/embedded-simple/src/main/resources/activemq-configuration.xml
@@ -22,15 +22,14 @@ under the License.
                xmlns="urn:activemq"
                xsi:schemaLocation="urn:activemq /schema/activemq-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>
 
+      <connectors>
+         <connector name="in-vm">vm://0</connector>
+      </connectors>
+
       <acceptors>
          <acceptor name="in-vm">vm://0</acceptor>
       </acceptors>

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/4b7eafdd/examples/jms/embedded-simple/src/main/resources/activemq-roles.properties
----------------------------------------------------------------------
diff --git a/examples/jms/embedded-simple/src/main/resources/activemq-roles.properties b/examples/jms/embedded-simple/src/main/resources/activemq-roles.properties
deleted file mode 100644
index 4e2d44c..0000000
--- a/examples/jms/embedded-simple/src/main/resources/activemq-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-6/blob/4b7eafdd/examples/jms/embedded-simple/src/main/resources/activemq-users.properties
----------------------------------------------------------------------
diff --git a/examples/jms/embedded-simple/src/main/resources/activemq-users.properties b/examples/jms/embedded-simple/src/main/resources/activemq-users.properties
deleted file mode 100644
index 4e2d44c..0000000
--- a/examples/jms/embedded-simple/src/main/resources/activemq-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


[2/5] activemq-6 git commit: Fix jms/rest example configuration

Posted by cl...@apache.org.
Fix jms/rest example configuration


Project: http://git-wip-us.apache.org/repos/asf/activemq-6/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-6/commit/9aaaf0a5
Tree: http://git-wip-us.apache.org/repos/asf/activemq-6/tree/9aaaf0a5
Diff: http://git-wip-us.apache.org/repos/asf/activemq-6/diff/9aaaf0a5

Branch: refs/heads/master
Commit: 9aaaf0a52354272001525fbc7630ac91653f0e99
Parents: 4b7eafd
Author: Howard Gao <hg...@redhat.com>
Authored: Wed Mar 11 10:54:10 2015 +0800
Committer: Howard Gao <hg...@redhat.com>
Committed: Wed Mar 11 16:50:53 2015 +0800

----------------------------------------------------------------------
 examples/jms/rest/dup-send/src/main/webapp/WEB-INF/web.xml        | 2 +-
 examples/jms/rest/javascript-chat/src/main/webapp/WEB-INF/web.xml | 2 +-
 examples/jms/rest/jms-to-rest/src/main/webapp/WEB-INF/web.xml     | 2 +-
 examples/jms/rest/push/src/main/webapp/WEB-INF/web.xml            | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-6/blob/9aaaf0a5/examples/jms/rest/dup-send/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/examples/jms/rest/dup-send/src/main/webapp/WEB-INF/web.xml b/examples/jms/rest/dup-send/src/main/webapp/WEB-INF/web.xml
index 1266949..cc75fc0 100644
--- a/examples/jms/rest/dup-send/src/main/webapp/WEB-INF/web.xml
+++ b/examples/jms/rest/dup-send/src/main/webapp/WEB-INF/web.xml
@@ -35,7 +35,7 @@ under the License.
 
 
     <listener>
-        <listener-class>org.apache.activemq.rest.integration.HornetqBootstrapListener</listener-class>
+        <listener-class>org.apache.activemq.rest.integration.ActiveMQBootstrapListener</listener-class>
     </listener>
 
     <listener>

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/9aaaf0a5/examples/jms/rest/javascript-chat/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/examples/jms/rest/javascript-chat/src/main/webapp/WEB-INF/web.xml b/examples/jms/rest/javascript-chat/src/main/webapp/WEB-INF/web.xml
index f4284d9..d3ceb42 100644
--- a/examples/jms/rest/javascript-chat/src/main/webapp/WEB-INF/web.xml
+++ b/examples/jms/rest/javascript-chat/src/main/webapp/WEB-INF/web.xml
@@ -29,7 +29,7 @@ under the License.
 
 
     <listener>
-        <listener-class>org.apache.activemq.rest.integration.HornetqBootstrapListener</listener-class>
+        <listener-class>org.apache.activemq.rest.integration.ActiveMQBootstrapListener</listener-class>
     </listener>
 
     <listener>

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/9aaaf0a5/examples/jms/rest/jms-to-rest/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/examples/jms/rest/jms-to-rest/src/main/webapp/WEB-INF/web.xml b/examples/jms/rest/jms-to-rest/src/main/webapp/WEB-INF/web.xml
index f4284d9..d3ceb42 100644
--- a/examples/jms/rest/jms-to-rest/src/main/webapp/WEB-INF/web.xml
+++ b/examples/jms/rest/jms-to-rest/src/main/webapp/WEB-INF/web.xml
@@ -29,7 +29,7 @@ under the License.
 
 
     <listener>
-        <listener-class>org.apache.activemq.rest.integration.HornetqBootstrapListener</listener-class>
+        <listener-class>org.apache.activemq.rest.integration.ActiveMQBootstrapListener</listener-class>
     </listener>
 
     <listener>

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/9aaaf0a5/examples/jms/rest/push/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/examples/jms/rest/push/src/main/webapp/WEB-INF/web.xml b/examples/jms/rest/push/src/main/webapp/WEB-INF/web.xml
index 8c96e25..e851072 100644
--- a/examples/jms/rest/push/src/main/webapp/WEB-INF/web.xml
+++ b/examples/jms/rest/push/src/main/webapp/WEB-INF/web.xml
@@ -29,7 +29,7 @@ under the License.
 
 
     <listener>
-        <listener-class>org.apache.activemq.rest.integration.HornetqBootstrapListener</listener-class>
+        <listener-class>org.apache.activemq.rest.integration.ActiveMQBootstrapListener</listener-class>
     </listener>
 
     <listener>


[3/5] activemq-6 git commit: Fix jms/scale-down example pom.xml

Posted by cl...@apache.org.
Fix jms/scale-down example pom.xml


Project: http://git-wip-us.apache.org/repos/asf/activemq-6/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-6/commit/5fe83ce8
Tree: http://git-wip-us.apache.org/repos/asf/activemq-6/tree/5fe83ce8
Diff: http://git-wip-us.apache.org/repos/asf/activemq-6/diff/5fe83ce8

Branch: refs/heads/master
Commit: 5fe83ce8d11ac8681d1cf6385bbb0d98266586ed
Parents: 9aaaf0a
Author: Howard Gao <hg...@redhat.com>
Authored: Wed Mar 11 11:26:04 2015 +0800
Committer: Howard Gao <hg...@redhat.com>
Committed: Wed Mar 11 16:50:55 2015 +0800

----------------------------------------------------------------------
 examples/jms/scale-down/pom.xml | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-6/blob/5fe83ce8/examples/jms/scale-down/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/scale-down/pom.xml b/examples/jms/scale-down/pom.xml
index 866371e..1419f88 100644
--- a/examples/jms/scale-down/pom.xml
+++ b/examples/jms/scale-down/pom.xml
@@ -90,12 +90,16 @@ under the License.
                         </goals>
                         <configuration>
                            <clientClass>org.apache.activemq.jms.example.ScaleDownExample</clientClass>
-                            <systemProperties>
-                                <property>
-                                    <name>exampleConfigDir</name>
-                                    <value>${basedir}/target/classes/activemq</value>
-                                </property>
-                            </systemProperties>
+                           <args>
+                              <param>tcp://localhost:61616</param>
+                              <param>tcp://localhost:61617</param>
+                           </args>
+                           <systemProperties>
+                              <property>
+                                 <name>exampleConfigDir</name>
+                                 <value>${basedir}/target/classes/activemq</value>
+                              </property>
+                           </systemProperties>
                         </configuration>
                      </execution>
                      <execution>


[5/5] activemq-6 git commit: This closes #170 on fixing examples

Posted by cl...@apache.org.
This closes #170 on fixing examples


Project: http://git-wip-us.apache.org/repos/asf/activemq-6/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-6/commit/670f5841
Tree: http://git-wip-us.apache.org/repos/asf/activemq-6/tree/670f5841
Diff: http://git-wip-us.apache.org/repos/asf/activemq-6/diff/670f5841

Branch: refs/heads/master
Commit: 670f5841ba092f6c5b528b61fe4b105b1a4f9a91
Parents: dba926a d7cd645
Author: Clebert Suconic <cl...@apache.org>
Authored: Wed Mar 11 19:15:07 2015 -0400
Committer: Clebert Suconic <cl...@apache.org>
Committed: Wed Mar 11 19:15:07 2015 -0400

----------------------------------------------------------------------
 .../core/config/impl/SecurityConfiguration.java | 23 +++++++++
 examples/jms/embedded-simple/readme.html        | 53 ++++++++++++++------
 .../activemq/jms/example/EmbeddedExample.java   | 11 ++++
 .../main/resources/activemq-configuration.xml   |  9 ++--
 .../main/resources/activemq-roles.properties    | 17 -------
 .../main/resources/activemq-users.properties    | 17 -------
 .../dup-send/src/main/webapp/WEB-INF/web.xml    |  2 +-
 .../src/main/webapp/WEB-INF/web.xml             |  2 +-
 .../jms-to-rest/src/main/webapp/WEB-INF/web.xml |  2 +-
 .../rest/push/src/main/webapp/WEB-INF/web.xml   |  2 +-
 examples/jms/scale-down/pom.xml                 | 16 +++---
 .../activemq/jms/example/MessageSender.java     | 18 ++++++-
 .../src/main/resources/spring-jms-beans.xml     | 23 +++++++++
 13 files changed, 131 insertions(+), 64 deletions(-)
----------------------------------------------------------------------



[4/5] activemq-6 git commit: Fix jms/spring-integration example

Posted by cl...@apache.org.
Fix jms/spring-integration example


Project: http://git-wip-us.apache.org/repos/asf/activemq-6/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-6/commit/d7cd6455
Tree: http://git-wip-us.apache.org/repos/asf/activemq-6/tree/d7cd6455
Diff: http://git-wip-us.apache.org/repos/asf/activemq-6/diff/d7cd6455

Branch: refs/heads/master
Commit: d7cd6455953fc4985fce387ea6b9ca6a4510ca6b
Parents: 5fe83ce
Author: Howard Gao <hg...@redhat.com>
Authored: Wed Mar 11 16:48:44 2015 +0800
Committer: Howard Gao <hg...@redhat.com>
Committed: Wed Mar 11 16:50:56 2015 +0800

----------------------------------------------------------------------
 .../core/config/impl/SecurityConfiguration.java | 23 ++++++++++++++++++++
 .../activemq/jms/example/MessageSender.java     | 18 ++++++++++++++-
 .../src/main/resources/spring-jms-beans.xml     | 23 ++++++++++++++++++++
 3 files changed, 63 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-6/blob/d7cd6455/activemq-server/src/main/java/org/apache/activemq/core/config/impl/SecurityConfiguration.java
----------------------------------------------------------------------
diff --git a/activemq-server/src/main/java/org/apache/activemq/core/config/impl/SecurityConfiguration.java b/activemq-server/src/main/java/org/apache/activemq/core/config/impl/SecurityConfiguration.java
index a40f361..45566e1 100644
--- a/activemq-server/src/main/java/org/apache/activemq/core/config/impl/SecurityConfiguration.java
+++ b/activemq-server/src/main/java/org/apache/activemq/core/config/impl/SecurityConfiguration.java
@@ -21,6 +21,7 @@ import org.apache.activemq.core.server.ActiveMQMessageBundle;
 
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
@@ -37,6 +38,28 @@ public class SecurityConfiguration
     */
    protected final Map<String, List<String>> roles = new HashMap<String, List<String>>();
 
+   public SecurityConfiguration()
+   {
+   }
+
+   public SecurityConfiguration(Map<String, String> users, Map<String, List<String>> roles)
+   {
+      Iterator<Map.Entry<String, String>> iter = users.entrySet().iterator();
+      while (iter.hasNext())
+      {
+         Map.Entry<String, String> entry = iter.next();
+         addUser(entry.getKey(), entry.getValue());
+      }
+      Iterator<Map.Entry<String, List<String>>> iter1 = roles.entrySet().iterator();
+      while (iter1.hasNext())
+      {
+         Map.Entry<String, List<String>> entry = iter1.next();
+         for (String role : entry.getValue())
+         {
+            addRole(entry.getKey(), role);
+         }
+      }
+   }
 
    public void addUser(final String user, final String password)
    {

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/d7cd6455/examples/jms/spring-integration/src/main/java/org/apache/activemq/jms/example/MessageSender.java
----------------------------------------------------------------------
diff --git a/examples/jms/spring-integration/src/main/java/org/apache/activemq/jms/example/MessageSender.java b/examples/jms/spring-integration/src/main/java/org/apache/activemq/jms/example/MessageSender.java
index 2b08ccc..1d5401d 100644
--- a/examples/jms/spring-integration/src/main/java/org/apache/activemq/jms/example/MessageSender.java
+++ b/examples/jms/spring-integration/src/main/java/org/apache/activemq/jms/example/MessageSender.java
@@ -19,6 +19,7 @@ package org.apache.activemq.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;
@@ -50,9 +51,10 @@ public class MessageSender
 
    public void send(String msg)
    {
+      Connection conn = null;
       try
       {
-         Connection conn = connectionFactory.createConnection();
+         conn = connectionFactory.createConnection();
          Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
          MessageProducer producer = session.createProducer(destination);
          TextMessage message = session.createTextMessage(msg);
@@ -62,5 +64,19 @@ public class MessageSender
       {
          ex.printStackTrace();
       }
+      finally
+      {
+         if (conn != null)
+         {
+            try
+            {
+               conn.close();
+            }
+            catch (JMSException e)
+            {
+               e.printStackTrace();
+            }
+         }
+      }
    }
 }

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/d7cd6455/examples/jms/spring-integration/src/main/resources/spring-jms-beans.xml
----------------------------------------------------------------------
diff --git a/examples/jms/spring-integration/src/main/resources/spring-jms-beans.xml b/examples/jms/spring-integration/src/main/resources/spring-jms-beans.xml
index bcbb01b..14bb5c8 100644
--- a/examples/jms/spring-integration/src/main/resources/spring-jms-beans.xml
+++ b/examples/jms/spring-integration/src/main/resources/spring-jms-beans.xml
@@ -24,8 +24,31 @@ under the License.
        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.spi.core.security.ActiveMQSecurityManagerImpl">
+      <constructor-arg>
+         <bean class="org.apache.activemq.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.integration.spring.SpringJmsBootstrap" init-method="start"
          destroy-method="stop">
+       <property name="SecurityManager" ref="securityManager"/>
    </bean>
 
    <bean id="connectionFactory" class="org.apache.activemq.jms.client.ActiveMQJMSConnectionFactory">