activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject svn commit: r748204 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/broker/region/Queue.java test/java/org/apache/activemq/JmsQueueBrowserTest.java
Date Thu, 26 Feb 2009 16:39:43 GMT
Author: dejanb
Date: Thu Feb 26 16:39:40 2009
New Revision: 748204

URL: http://svn.apache.org/viewvc?rev=748204&view=rev
Log:
fix for https://issues.apache.org/activemq/browse/AMQ-1859

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.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/Queue.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java?rev=748204&r1=748203&r2=748204&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java
Thu Feb 26 16:39:40 2009
@@ -287,8 +287,8 @@
                 QueueBrowserSubscription browserSubscription = (QueueBrowserSubscription)
sub;
             	
                 // do again in iterate to ensure new messages are dispatched
-                doPageIn(false);
-            
+                pageInMessages(false);
+                
             	synchronized (pagedInMessages) {
             	    if (!pagedInMessages.isEmpty()) {
             	        BrowserDispatch browserDispatch = new BrowserDispatch(browserSubscription,
pagedInMessages.values());
@@ -1339,6 +1339,10 @@
             Subscription target = null;
             int interestCount=0;
             for (Subscription s : consumers) {
+            	if (s instanceof QueueBrowserSubscription) {
+            		interestCount++;
+            		continue;
+            	}
                 if (dispatchSelector.canSelect(s, node)) {
                     if (!fullConsumers.contains(s)) {
                         if (!s.isFull()) {

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=748204&r1=748203&r2=748204&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
Thu Feb 26 16:39:40 2009
@@ -95,4 +95,37 @@
         consumer.close();
 
     }
+    
+    public void testBrowseReceive() throws Exception {
+        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        ActiveMQQueue destination = new ActiveMQQueue("TEST");
+       
+        connection.start();
+
+        Message[] outbound = new Message[]{session.createTextMessage("First Message"),
+                                           session.createTextMessage("Second Message"),
+                                           session.createTextMessage("Third Message")};
+
+        
+        MessageProducer producer = session.createProducer(destination);
+        producer.send(outbound[0]);
+        
+        // create browser first
+        QueueBrowser browser = session.createBrowser((Queue) destination);
+        Enumeration enumeration = browser.getEnumeration();
+        
+        // create consumer
+        MessageConsumer consumer = session.createConsumer(destination);
+        
+        // browse the first message
+        assertTrue("should have received the fisrts message", enumeration.hasMoreElements());
+        assertEquals(outbound[0], (Message) enumeration.nextElement());
+        
+        // Receive the first message.
+        assertEquals(outbound[0], consumer.receive(1000));
+        consumer.close();
+        browser.close();
+        producer.close();
+
+    }    
 }



Mime
View raw message