activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject svn commit: r1088593 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/broker/region/QueueBrowserSubscription.java test/java/org/apache/activemq/JmsQueueBrowserTest.java
Date Mon, 04 Apr 2011 12:27:12 GMT
Author: dejanb
Date: Mon Apr  4 12:27:11 2011
New Revision: 1088593

URL: http://svn.apache.org/viewvc?rev=1088593&view=rev
Log:
https://issues.apache.org/jira/browse/AMQ-3262 - queue browser and message order

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/QueueBrowserSubscription.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsQueueBrowserTest.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/QueueBrowserSubscription.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/QueueBrowserSubscription.java?rev=1088593&r1=1088592&r2=1088593&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/QueueBrowserSubscription.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/QueueBrowserSubscription.java
Mon Apr  4 12:27:11 2011
@@ -17,6 +17,8 @@
 package org.apache.activemq.broker.region;
 
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
 import javax.jms.InvalidSelectorException;
 import org.apache.activemq.broker.Broker;
 import org.apache.activemq.broker.ConnectionContext;
@@ -81,4 +83,12 @@ public class QueueBrowserSubscription ex
         checkDone();
     }
 
+
+    @Override
+    public List<MessageReference> remove(ConnectionContext context, Destination destination)
throws Exception {
+        super.remove(context, destination);
+        // there's no unacked messages that needs to be redelivered
+        // in case of browser
+        return new ArrayList<MessageReference>();
+    }
 }

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsQueueBrowserTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsQueueBrowserTest.java?rev=1088593&r1=1088592&r2=1088593&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsQueueBrowserTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsQueueBrowserTest.java
Mon Apr  4 12:27:11 2011
@@ -187,4 +187,50 @@ public class JmsQueueBrowserTest extends
         assertFalse("nothing left in the browser", browserView.hasMoreElements());
         assertNull("consumer finished", consumer.receiveNoWait());
     }
+
+    public void testBrowseClose() throws Exception {
+        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        ActiveMQQueue destination = new ActiveMQQueue("TEST");
+
+        connection.start();
+
+        TextMessage[] outbound = new TextMessage[]{session.createTextMessage("First Message"),
+                                           session.createTextMessage("Second Message"),
+                                           session.createTextMessage("Third Message")};
+
+
+        MessageProducer producer = session.createProducer(destination);
+        producer.send(outbound[0]);
+        producer.send(outbound[1]);
+        producer.send(outbound[2]);
+
+
+        // create browser first
+        QueueBrowser browser = session.createBrowser((Queue) destination);
+        Enumeration enumeration = browser.getEnumeration();
+
+
+        // browse some messages
+        assertEquals(outbound[0], (Message) enumeration.nextElement());
+        assertEquals(outbound[1], (Message) enumeration.nextElement());
+        //assertEquals(outbound[2], (Message) enumeration.nextElement());
+
+
+        browser.close();
+
+        // create consumer
+        MessageConsumer consumer = session.createConsumer(destination);
+
+        // Receive the first message.
+        TextMessage msg = (TextMessage)consumer.receive(1000);
+        assertEquals("Expected " + outbound[0].getText() + " but received " + msg.getText(),
 outbound[0], msg);
+        msg = (TextMessage)consumer.receive(1000);
+        assertEquals("Expected " + outbound[1].getText() + " but received " + msg.getText(),
outbound[1], msg);
+        msg = (TextMessage)consumer.receive(1000);
+        assertEquals("Expected " + outbound[2].getText() + " but received " + msg.getText(),
outbound[2], msg);
+
+        consumer.close();
+        producer.close();
+
+    }
 }



Mime
View raw message