[jboss-cvs] JBoss Messaging SVN: r6485 - in trunk: examples/jms and 9 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sat Apr 18 09:43:37 EDT 2009


Author: timfox
Date: 2009-04-18 09:43:37 -0400 (Sat, 18 Apr 2009)
New Revision: 6485

Added:
   trunk/examples/jms/delayed-redelivery/
   trunk/examples/jms/delayed-redelivery/build.xml
   trunk/examples/jms/delayed-redelivery/readme.html
   trunk/examples/jms/delayed-redelivery/server0/
   trunk/examples/jms/delayed-redelivery/server0/client-jndi.properties
   trunk/examples/jms/delayed-redelivery/server0/jbm-configuration.xml
   trunk/examples/jms/delayed-redelivery/server0/jbm-jms.xml
   trunk/examples/jms/delayed-redelivery/server0/jbm-queues.xml
   trunk/examples/jms/delayed-redelivery/server0/jbm-security.xml
   trunk/examples/jms/delayed-redelivery/server0/jbm-standalone-beans.xml
   trunk/examples/jms/delayed-redelivery/src/
   trunk/examples/jms/delayed-redelivery/src/org/
   trunk/examples/jms/delayed-redelivery/src/org/jboss/
   trunk/examples/jms/delayed-redelivery/src/org/jboss/jms/
   trunk/examples/jms/delayed-redelivery/src/org/jboss/jms/example/
   trunk/examples/jms/delayed-redelivery/src/org/jboss/jms/example/DelayedRedeliveryExample.java
Modified:
   trunk/.classpath
   trunk/examples/jms/dead-letter/server0/jbm-queues.xml
   trunk/examples/jms/expiry/server0/jbm-queues.xml
Log:
delayed redelivery example

Modified: trunk/.classpath
===================================================================
--- trunk/.classpath	2009-04-17 23:01:04 UTC (rev 6484)
+++ trunk/.classpath	2009-04-18 13:43:37 UTC (rev 6485)
@@ -29,6 +29,7 @@
 	<classpathentry kind="src" path="examples/jms/bridge/src"/>
 	<classpathentry kind="src" path="examples/jms/common/src"/>
 	<classpathentry kind="src" path="examples/jms/dead-letter/src"/>
+	<classpathentry kind="src" path="examples/jms/delayed-redelivery/src"/>
 	<classpathentry kind="src" path="examples/jms/divert/src"/>
 	<classpathentry kind="src" path="examples/jms/durable-subscription/src"/>
 	<classpathentry kind="src" path="examples/jms/expiry/src"/>

Modified: trunk/examples/jms/dead-letter/server0/jbm-queues.xml
===================================================================
--- trunk/examples/jms/dead-letter/server0/jbm-queues.xml	2009-04-17 23:01:04 UTC (rev 6484)
+++ trunk/examples/jms/dead-letter/server0/jbm-queues.xml	2009-04-18 13:43:37 UTC (rev 6485)
@@ -3,7 +3,7 @@
             xsi:schemaLocation="urn:jboss:messaging ../schemas/jbm-queues.xsd ">
 
    <!--security for example queue-->
-   <security match="jms.queue.exampleQueue">
+   <security match="jms.#">
       <permission type="createDurableQueue" roles="guest"/>
       <permission type="deleteDurableQueue" roles="guest"/>
       <permission type="createTempQueue" roles="guest"/>
@@ -12,16 +12,6 @@
       <permission type="send" roles="guest"/>
    </security>
 
-   <!--security for dead letter queue-->
-   <security match="jms.queue.deadLetterQueue">
-      <permission type="createDurableQueue" roles="guest"/>
-      <permission type="deleteDurableQueue" roles="guest"/>
-      <permission type="createTempQueue" roles="guest"/>
-      <permission type="deleteTempQueue" roles="guest"/>
-      <permission type="consume" roles="guest"/>
-      <permission type="send" roles="guest"/>
-   </security>
-   
    <!--override the max-delivery-attempts and dead letter address for the example queue-->
    <address-settings match="jms.queue.exampleQueue">
       <dead-letter-address>jms.queue.deadLetterQueue</dead-letter-address>

Added: trunk/examples/jms/delayed-redelivery/build.xml
===================================================================
--- trunk/examples/jms/delayed-redelivery/build.xml	                        (rev 0)
+++ trunk/examples/jms/delayed-redelivery/build.xml	2009-04-18 13:43:37 UTC (rev 6485)
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE project [
+      <!ENTITY libraries SYSTEM "../../../thirdparty/libraries.ent">
+      ]>
+
+<!-- =========================================================================================== -->
+<!--                                                                                             -->
+<!-- JBoss, Home of Professional Open Source                                                     -->
+<!-- Copyright 2005, JBoss Inc., and individual contributors as indicated                        -->
+<!-- by the @authors tag. See the copyright.txt in the distribution for a                        -->
+<!-- full listing of individual contributors.                                                    -->
+<!--                                                                                             -->
+<!-- This is free software; you can redistribute it and/or modify it                             -->
+<!-- under the terms of the GNU Lesser General Public License as                                 -->
+<!-- published by the Free Software Foundation; either version 2.1 of                            -->
+<!-- the License, or (at your option) any later version.                                         -->
+<!--                                                                                             -->
+<!-- This software is distributed in the hope that it will be useful,                            -->
+<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of                              -->
+<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU                            -->
+<!-- Lesser General Public License for more details.                                             -->
+<!--                                                                                             -->
+<!-- You should have received a copy of the GNU Lesser General Public                            -->
+<!-- License along with this software; if not, write to the Free                                 -->
+<!-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA                          -->
+<!-- 02110-1301 USA, or see the FSF site: http://www.fsf.org.                                    -->
+<!--                                                                                             -->
+<!-- =========================================================================================== -->
+
+
+<project default="run" name="JBoss Messaging Delayed Redelivery Example">
+
+   <import file="../common/build.xml"/>
+
+   <target name="run">
+      <antcall target="runExample">
+         <param name="example.classname" value="org.jboss.jms.example.DelayedRedeliveryExample"/>
+      </antcall>
+   </target>
+
+   <target name="runRemote">
+      <antcall target="runExample">
+         <param name="example.classname" value="org.jboss.jms.example.DelayedRedeliveryExample"/>
+         <param name="jbm.example.runServer" value="false"/>
+      </antcall>
+   </target>
+
+</project>
\ No newline at end of file

Added: trunk/examples/jms/delayed-redelivery/readme.html
===================================================================
--- trunk/examples/jms/delayed-redelivery/readme.html	                        (rev 0)
+++ trunk/examples/jms/delayed-redelivery/readme.html	2009-04-18 13:43:37 UTC (rev 6485)
@@ -0,0 +1,160 @@
+<html>
+  <head>
+    <title>JBoss Messaging Delayed Redelivery Example</title>
+    <link rel="stylesheet" type="text/css" href="../common/common.css">
+  </head>
+  <body>
+     <h1>JBoss Messaging Delayed Redelivery Example</h1>
+     
+     <p>This example demonstrates how JBoss Messaging can be configured to provide a delayed redelivery in the case
+     a message needs to be redelivered.</p>
+     <p>Delaying redelivery can often be useful in the case that clients regularly fail or roll-back. Without a delayed
+     redelivery, the system can get into a "thrashing" state, with delivery being attempted, the client rolling back, and
+     delivery being re-attempted ad infinitum in quick succession, using up valuable CPU and network resources.</p>
+     <p>Re-delivery occurs when the session is closed with unacknowledged messages. The unacknowledged messages will
+     be redelivered.</p>
+     <p>By providing a redelivery delay, it can be specified that a delay of, say, 10 seconds is implemented between rollback
+     and redelivery. The specific delay is configurable on both a global and per destination level, by using wild-card
+     matching on the address settings.</p>
+
+     <h2>Example setup</h2>
+     <p>Redelivery delay is specified in the queue settings configuration file <a href="server0/jbm-queues.xml">jbm-queues.xml</a>:</p>
+     <p>In this example we set the redelivery delay to 5 seconds for the specific example queue. We could set redelivery delay on
+     on multiple queues by specifying a wild-card in the match, e.g. <code>match="jms.#"</code> would apply the settings
+     to all JMS queues and topics.</p>
+     <p>We then consume a message in a transacted session, and rollback, and note that the message is not redelivered until
+     after 5 seconds.</p>
+     <pre>
+         <code>&lt;address-settings match="jms.queue.exampleQueue"&gt;           
+            &lt;redelivey-delay&gt;5000&lt;/redelivey-delay&gt;
+         &lt;/address-settings&gt;
+         </code>
+     </pre>                 
+     <p><i>To run the example, simply type <code>ant</code> from this directory</i></p>
+     <ol>
+        <li>Create an initial context to perform the JNDI lookup.</li>
+        <pre>
+           <code>initialContext = getContext(0);</code>
+        </pre>
+
+        <li>Perform a lookup on the queue</li>
+        <pre>
+           <code>Queue queue = (Queue)initialContext.lookup("/queue/exampleQueue");</code>
+        </pre>
+
+        <li>Perform a lookup on the Connection Factory</li>
+        <pre>
+           <code>ConnectionFactory cf = (ConnectionFactory)initialContext.lookup("/ConnectionFactory");</code>
+        </pre>
+
+        <li>Create a JMS Connection</li>
+        <pre>
+           <code>connection = cf.createConnection();</code>
+        </pre>
+
+        <li>Create a transacted JMS Session
+        <pre>
+           <code>Session session = connection.createSession(true, 0);</code>
+        </pre>
+
+        <li>Create a JMS Message Producer</li>
+        <pre>
+          <code>MessageProducer producer = session.createProducer(queue);</code>
+       </pre>
+       
+        <li>Create a Text Message</li>
+        <pre>
+            <code>TextMessage message = session.createTextMessage("this is a text message");</code>
+        </pre>
+
+        <li>Send the Message</li>
+        <pre>
+            <code>producer.send(message);</code>
+        </pre>
+        
+       <li>We commit the session to effectively send the message to the queue</li>
+        <pre>
+            <code>session.commit();</code>
+        </pre>
+
+        <li>We create a JMS message consumer on the queue</li>
+        <pre>
+            <code>MessageConsumer messageConsumer = session.createConsumer(queue);</code>
+        </pre>
+        
+        <li>We start the connection. In order for delivery to occur on any consumers or subscribers on a connection, the connection must be started</li>
+        <pre>
+           <code>connection.start();</code>
+        </pre>
+        
+        <li>We receive the message...</li>
+        <pre>
+            <code>TextMessage messageReceived = (TextMessage)messageConsumer.receive(5000);
+            System.out.println("1st delivery from " + queue.getQueueName() + ": " + messageReceived.getText());</code>            
+        </pre>
+        
+        <li>...but we roll back the session. the message returns to the queue, but only after a 
+            5 second delay</li>
+        <pre>
+            <code>session.rollback();</code>
+        </pre>
+        
+        <li>We try to receive the message but it's being delayed</li>
+        <pre>
+            <code>
+         messageReceived = (TextMessage)messageConsumer.receive(3000);
+         
+         if (messageReceived != null)
+         {
+            return false;
+         }
+         
+         System.out.println("Redelivery has been delayed so received message is " + messageReceived);
+            
+            </code>
+        </pre>
+  
+       <li>We try and receive the message again, this time we should get it</li>
+       <pre>
+           <code>             
+         messageReceived = (TextMessage)messageConsumer.receive(3000);
+         
+         System.out.println("2nd delivery from " + queue.getQueueName() + ": " + messageReceived.getText());
+           </code>
+       </pre>
+              
+        <li>We rollback the session again to cause another redelivery, and we time how long this one takes</code>
+        <pre>
+           <code>
+         long start = System.currentTimeMillis();
+         
+         session.rollback();
+                         
+         messageReceived = (TextMessage)messageConsumer.receive(8000);
+         
+         long end = System.currentTimeMillis();
+         
+         System.out.println("3nd delivery from " + queue.getQueueName() + ": " + messageReceived.getText() +
+                            " after " + (end - start) + " milliseconds.");           
+           </code>
+        </pre>
+        
+        <li>And finally, <b>always</b> remember to close your JMS connections and resources after use, in a <code>finally</code> block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects</li>
+
+        <pre>
+           <code>finally
+           {
+              if (initialContext != null)
+              {
+                initialContext.close();
+              }
+              if (connection != null)
+              {
+                 connection.close();
+              }
+           }</code>
+        </pre>
+     </ol>
+    
+  </body>
+</html>
\ No newline at end of file

Added: trunk/examples/jms/delayed-redelivery/server0/client-jndi.properties
===================================================================
--- trunk/examples/jms/delayed-redelivery/server0/client-jndi.properties	                        (rev 0)
+++ trunk/examples/jms/delayed-redelivery/server0/client-jndi.properties	2009-04-18 13:43:37 UTC (rev 6485)
@@ -0,0 +1,3 @@
+java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.provider.url=jnp://localhost:1099
+java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces

Added: trunk/examples/jms/delayed-redelivery/server0/jbm-configuration.xml
===================================================================
--- trunk/examples/jms/delayed-redelivery/server0/jbm-configuration.xml	                        (rev 0)
+++ trunk/examples/jms/delayed-redelivery/server0/jbm-configuration.xml	2009-04-18 13:43:37 UTC (rev 6485)
@@ -0,0 +1,29 @@
+<deployment xmlns="urn:jboss:messaging"
+            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="urn:jboss:messaging ../schemas/jbm-configuration.xsd">
+   <configuration>
+
+      <!-- Connectors -->
+
+      <connectors>
+         <connector name="netty-connector">
+            <factory-class>org.jboss.messaging.integration.transports.netty.NettyConnectorFactory</factory-class>
+            <param key="jbm.remoting.netty.port" value="5445" type="Integer"/>
+         </connector>
+      </connectors>
+      
+      <!-- Acceptors -->
+      <acceptors>
+         <acceptor name="netty-acceptor">
+            <factory-class>org.jboss.messaging.integration.transports.netty.NettyAcceptorFactory</factory-class>
+            <param key="jbm.remoting.netty.port" value="5445" type="Integer"/>
+         </acceptor>
+      </acceptors>
+
+      <!-- Other config -->
+
+      <journal-min-files>2</journal-min-files>
+
+   </configuration>
+
+</deployment>

Added: trunk/examples/jms/delayed-redelivery/server0/jbm-jms.xml
===================================================================
--- trunk/examples/jms/delayed-redelivery/server0/jbm-jms.xml	                        (rev 0)
+++ trunk/examples/jms/delayed-redelivery/server0/jbm-jms.xml	2009-04-18 13:43:37 UTC (rev 6485)
@@ -0,0 +1,25 @@
+<deployment xmlns="urn:jboss:messaging"
+            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="urn:jboss:messaging ../schemas/jbm-jms.xsd ">
+   <!--the connection factory used by the example-->
+   <connection-factory name="ConnectionFactory">
+      <connector-ref connector-name="netty-connector"/>
+      <entries>
+         <entry name="ConnectionFactory"/>
+         <entry name="XAConnectionFactory"/>
+         <entry name="java:/ConnectionFactory"/>
+         <entry name="java:/XAConnectionFactory"/>
+      </entries>
+   </connection-factory>
+
+   <!--the queue used by the example-->
+   <queue name="exampleQueue">
+      <entry name="/queue/exampleQueue"/>
+   </queue>
+
+   <!-- the dead letter queue where dead messages will be sent-->
+   <queue name="deadLetterQueue">
+      <entry name="/queue/deadLetterQueue"/>
+   </queue>
+
+</deployment>
\ No newline at end of file

Added: trunk/examples/jms/delayed-redelivery/server0/jbm-queues.xml
===================================================================
--- trunk/examples/jms/delayed-redelivery/server0/jbm-queues.xml	                        (rev 0)
+++ trunk/examples/jms/delayed-redelivery/server0/jbm-queues.xml	2009-04-18 13:43:37 UTC (rev 6485)
@@ -0,0 +1,22 @@
+<settings xmlns="urn:jboss:messaging"
+            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="urn:jboss:messaging ../schemas/jbm-queues.xsd ">
+
+   <!--security for example queue-->
+   <security match="jms.#">
+      <permission type="createDurableQueue" roles="guest"/>
+      <permission type="deleteDurableQueue" roles="guest"/>
+      <permission type="createTempQueue" roles="guest"/>
+      <permission type="deleteTempQueue" roles="guest"/>
+      <permission type="consume" roles="guest"/>
+      <permission type="send" roles="guest"/>
+   </security>
+   
+   <!--override the redelivery-delay  for the example queue-->
+   <address-settings match="jms.queue.exampleQueue">
+   
+      <redelivery-delay>5000</redelivery-delay>
+      
+   </address-settings>
+   
+</settings>

Added: trunk/examples/jms/delayed-redelivery/server0/jbm-security.xml
===================================================================
--- trunk/examples/jms/delayed-redelivery/server0/jbm-security.xml	                        (rev 0)
+++ trunk/examples/jms/delayed-redelivery/server0/jbm-security.xml	2009-04-18 13:43:37 UTC (rev 6485)
@@ -0,0 +1,7 @@
+<deployment xmlns="urn:jboss:messaging" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="urn:jboss:messaging ../schemas/jbm-security.xsd ">
+   <!-- the default user.  this is used where username is null-->
+   <defaultuser name="guest" password="guest">
+      <role name="guest"/>
+   </defaultuser>
+</deployment>
\ No newline at end of file

Added: trunk/examples/jms/delayed-redelivery/server0/jbm-standalone-beans.xml
===================================================================
--- trunk/examples/jms/delayed-redelivery/server0/jbm-standalone-beans.xml	                        (rev 0)
+++ trunk/examples/jms/delayed-redelivery/server0/jbm-standalone-beans.xml	2009-04-18 13:43:37 UTC (rev 6485)
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+   <bean name="Naming" class="org.jnp.server.NamingBeanImpl"/>
+
+   <!-- JNDI server. Disable this if you don't want JNDI -->
+   <bean name="JNDIServer" class="org.jnp.server.Main">
+      <property name="namingInfo">
+         <inject bean="Naming"/>
+      </property>
+      <property name="port">1099</property>
+      <property name="bindAddress">localhost</property>
+      <property name="rmiPort">1098</property>
+      <property name="rmiBindAddress">localhost</property>
+   </bean>
+   
+   <!-- MBean server -->
+   <bean name="MBeanServer" class="javax.management.MBeanServer">
+      <constructor factoryClass="java.lang.management.ManagementFactory"
+                   factoryMethod="getPlatformMBeanServer"/>
+   </bean> 
+
+   <!-- The core configuration -->
+   <bean name="Configuration" class="org.jboss.messaging.core.config.impl.FileConfiguration"/>
+
+   <!-- The security manager -->
+   <bean name="JBMSecurityManager" class="org.jboss.messaging.core.security.impl.JBMSecurityManagerImpl">
+      <start ignored="true"/>
+      <stop ignored="true"/>
+   </bean>
+
+	<!-- The core server -->
+   <bean name="MessagingServer" class="org.jboss.messaging.core.server.impl.MessagingServerImpl"> 
+      <constructor>
+         <parameter>
+            <inject bean="Configuration"/>
+         </parameter>
+         <parameter>
+            <inject bean="MBeanServer"/>
+         </parameter>
+         <parameter>
+            <inject bean="JBMSecurityManager"/>
+         </parameter>        
+      </constructor>         
+   </bean>
+   
+   <!-- The JMS server -->
+   <bean name="JMSServerManager" class="org.jboss.messaging.jms.server.impl.JMSServerManagerImpl">
+      <constructor>         
+         <parameter>
+            <inject bean="MessagingServer"/>
+         </parameter>        
+      </constructor>
+   </bean>
+
+
+</deployment>
\ No newline at end of file

Added: trunk/examples/jms/delayed-redelivery/src/org/jboss/jms/example/DelayedRedeliveryExample.java
===================================================================
--- trunk/examples/jms/delayed-redelivery/src/org/jboss/jms/example/DelayedRedeliveryExample.java	                        (rev 0)
+++ trunk/examples/jms/delayed-redelivery/src/org/jboss/jms/example/DelayedRedeliveryExample.java	2009-04-18 13:43:37 UTC (rev 6485)
@@ -0,0 +1,144 @@
+/*
+   * JBoss, Home of Professional Open Source
+   * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+   * by the @authors tag. See the copyright.txt in the distribution for a
+   * full listing of individual contributors.
+   *
+   * This is free software; you can redistribute it and/or modify it
+   * under the terms of the GNU Lesser General Public License as
+   * published by the Free Software Foundation; either version 2.1 of
+   * the License, or (at your option) any later version.
+   *
+   * This software is distributed in the hope that it will be useful,
+   * but WITHOUT ANY WARRANTY; without even the implied warranty of
+   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+   * Lesser General Public License for more details.
+   *
+   * You should have received a copy of the GNU Lesser General Public
+   * License along with this software; if not, write to the Free
+   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+   */
+package org.jboss.jms.example;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.naming.InitialContext;
+
+/**
+ * This example demonstrates how JBoss Messaging can be configured with a redelivery delay in the event a message
+ * is redelivered.
+ * 
+ * Please see the readme.html for more information
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public class DelayedRedeliveryExample extends JMSExample
+{
+   public static void main(String[] args)
+   {
+      new DelayedRedeliveryExample().run(args);
+   }
+
+   public boolean runExample() throws Exception
+   {
+      Connection connection = null;
+      InitialContext initialContext = null;
+      
+      try
+      {
+         // Step 1. Create an initial context to perform the JNDI lookup.
+         initialContext = getContext(0);
+
+         // Step 2. Perform a lookup on the queue
+         Queue queue = (Queue)initialContext.lookup("/queue/exampleQueue");
+
+         // Step 3. Perform a lookup on the Connection Factory
+         ConnectionFactory cf = (ConnectionFactory)initialContext.lookup("/ConnectionFactory");
+
+         // Step 4. Create a JMS Connection
+         connection = cf.createConnection();
+
+         // Step 5. Create a transacted JMS Session
+         Session session = connection.createSession(true, 0);
+
+         // Step 6. Create a JMS Message Producer
+         MessageProducer producer = session.createProducer(queue);
+
+         // Step 7. Create a Text Message
+         TextMessage message = session.createTextMessage("this is a text message");
+
+         // Step 8. Send the Message
+         producer.send(message);
+         
+         System.out.println("Sent message to " + queue.getQueueName() + ": " + message.getText());
+
+         // Step 9. Commit the session to effectively send the message
+         session.commit();
+
+         // Step 10. Create a JMS Message Consumer for the queue
+         MessageConsumer messageConsumer = session.createConsumer(queue);
+
+         // Step 11. Start the Connection
+         connection.start();
+
+         // Step 12. We receive a message...
+         TextMessage messageReceived = (TextMessage)messageConsumer.receive(5000);
+         System.out.println("1st delivery from " + queue.getQueueName() + ": " + messageReceived.getText());
+
+         // Step 13. ... but we roll back the session. the message returns to the queue, but only after a 
+         // 5 second delay
+         session.rollback();
+                  
+         // Step 14. We try to receive the message but it's being delayed
+         messageReceived = (TextMessage)messageConsumer.receive(3000);
+         
+         if (messageReceived != null)
+         {
+            return false;
+         }
+         
+         System.out.println("Redelivery has been delayed so received message is " + messageReceived);
+         
+         // Step 15. We try and receive the message again, this time we should get it
+         
+         messageReceived = (TextMessage)messageConsumer.receive(3000);
+         
+         System.out.println("2nd delivery from " + queue.getQueueName() + ": " + messageReceived.getText());
+         
+         // Step 16. We rollback the session again to cause another redelivery, and we time how long this one takes
+         
+         long start = System.currentTimeMillis();
+         
+         session.rollback();
+                         
+         messageReceived = (TextMessage)messageConsumer.receive(8000);
+         
+         long end = System.currentTimeMillis();
+         
+         System.out.println("3nd delivery from " + queue.getQueueName() + ": " + messageReceived.getText() +
+                            " after " + (end - start) + " milliseconds.");
+                 
+         return true;
+      }
+      finally
+      {
+         // Step 17. Be sure to close our JMS resources!
+         if (initialContext != null)
+         {
+            initialContext.close();
+         }
+         if (connection != null)
+         {
+            connection.close();
+         }
+      }
+   }
+
+}

Modified: trunk/examples/jms/expiry/server0/jbm-queues.xml
===================================================================
--- trunk/examples/jms/expiry/server0/jbm-queues.xml	2009-04-17 23:01:04 UTC (rev 6484)
+++ trunk/examples/jms/expiry/server0/jbm-queues.xml	2009-04-18 13:43:37 UTC (rev 6485)
@@ -3,7 +3,7 @@
             xsi:schemaLocation="urn:jboss:messaging ../schemas/jbm-queues.xsd ">
 
    <!--security for example queue-->
-   <security match="jms.queue.exampleQueue">
+   <security match="jms.#">
       <permission type="createDurableQueue" roles="guest"/>
       <permission type="deleteDurableQueue" roles="guest"/>
       <permission type="createTempQueue" roles="guest"/>
@@ -12,16 +12,6 @@
       <permission type="send" roles="guest"/>
    </security>
 
-   <!--security for dead letter queue-->
-   <security match="jms.queue.expiryQueue">
-      <permission type="createDurableQueue" roles="guest"/>
-      <permission type="deleteDurableQueue" roles="guest"/>
-      <permission type="createTempQueue" roles="guest"/>
-      <permission type="deleteTempQueue" roles="guest"/>
-      <permission type="consume" roles="guest"/>
-      <permission type="send" roles="guest"/>
-   </security>
-
    <!--override the expiry address for the example-->
    <address-settings match="jms.queue.exampleQueue">
       <expiry-address>jms.queue.expiryQueue</expiry-address>




More information about the jboss-cvs-commits mailing list