activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject svn commit: r889677 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/broker/region/ test/java/org/apache/activemq/ test/java/org/apache/activemq/usecases/
Date Fri, 11 Dec 2009 16:11:07 GMT
Author: dejanb
Date: Fri Dec 11 16:11:07 2009
New Revision: 889677

URL: http://svn.apache.org/viewvc?rev=889677&view=rev
Log:
https://issues.apache.org/activemq/browse/AMQ-2529 - browse over network

Added:
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/BrowseOverNetworkTest.java
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/JmsMultipleBrokersTestSupport.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=889677&r1=889676&r2=889677&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
Fri Dec 11 16:11:07 2009
@@ -67,6 +67,9 @@
      */
     protected void acknowledge(ConnectionContext context, final MessageAck ack, final MessageReference
n)
         throws IOException {
+    	if (info.isNetworkSubscription()) {
+    		super.acknowledge(context, ack, n);
+    	}
     }
 
     synchronized public void incrementQueueRef() {

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsMultipleBrokersTestSupport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsMultipleBrokersTestSupport.java?rev=889677&r1=889676&r2=889677&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsMultipleBrokersTestSupport.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsMultipleBrokersTestSupport.java
Fri Dec 11 16:11:07 2009
@@ -36,6 +36,8 @@
 import javax.jms.JMSException;
 import javax.jms.MessageConsumer;
 import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.QueueBrowser;
 import javax.jms.Session;
 import javax.jms.TextMessage;
 import javax.jms.Topic;
@@ -229,6 +231,14 @@
         }
         return null;
     }
+    
+    protected QueueBrowser createBrowser(String brokerName, Destination dest) throws Exception
{
+        BrokerItem brokerItem = brokers.get(brokerName);
+        if (brokerItem != null) {
+            return brokerItem.createBrowser(dest);
+        }
+        return null;
+    }
 
     protected MessageConsumer createDurableSubscriber(String brokerName, Topic dest, String
name) throws Exception {
         BrokerItem brokerItem = brokers.get(brokerName);
@@ -434,6 +444,13 @@
             consumers.put(client, messageIdList);
             return client;
         }
+        
+        public QueueBrowser createBrowser(Destination dest) throws Exception {
+            Connection c = createConnection();
+            c.start();
+            Session s = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
+            return s.createBrowser((Queue)dest);
+        }
 
         public MessageConsumer createDurableSubscriber(Topic dest, String name) throws Exception
{
             Connection c = createConnection();

Added: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/BrowseOverNetworkTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/BrowseOverNetworkTest.java?rev=889677&view=auto
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/BrowseOverNetworkTest.java
(added)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/BrowseOverNetworkTest.java
Fri Dec 11 16:11:07 2009
@@ -0,0 +1,84 @@
+/**
+ * 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.
+ */
+package org.apache.activemq.usecases;
+
+import java.net.URI;
+import java.util.Enumeration;
+
+import javax.jms.Destination;
+import javax.jms.MessageConsumer;
+import javax.jms.QueueBrowser;
+
+import org.apache.activemq.JmsMultipleBrokersTestSupport;
+import org.apache.activemq.broker.region.QueueSubscription;
+import org.apache.activemq.util.MessageIdList;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class BrowseOverNetworkTest extends JmsMultipleBrokersTestSupport {
+    private static final Log LOG = LogFactory.getLog(QueueSubscription.class);
+    protected static final int MESSAGE_COUNT = 10;
+
+    public void testBrowse() throws Exception {
+        bridgeBrokers("BrokerA", "BrokerB");
+
+        startAllBrokers();
+
+        Destination dest = createDestination("TEST.FOO", false);
+
+        sendMessages("BrokerA", dest, MESSAGE_COUNT);
+
+        browseMessages(dest);
+
+        Thread.sleep(2000);
+
+        MessageConsumer clientA = createConsumer("BrokerA", dest);
+        MessageIdList msgsA = getConsumerMessages("BrokerA", clientA);
+        msgsA.waitForMessagesToArrive(MESSAGE_COUNT);
+
+        Thread.sleep(2000);
+        MessageConsumer clientB = createConsumer("BrokerB", dest);
+        MessageIdList msgsB = getConsumerMessages("BrokerB", clientB);
+        msgsB.waitForMessagesToArrive(MESSAGE_COUNT);
+
+        LOG.info("A+B: " + msgsA.getMessageCount() + "+"
+                + msgsB.getMessageCount());
+        assertEquals(MESSAGE_COUNT, msgsA.getMessageCount()
+                + msgsB.getMessageCount());
+    }
+
+    protected void browseMessages(Destination dest) throws Exception {
+        QueueBrowser browser = createBrowser("BrokerB", dest);
+        Enumeration msgs = browser.getEnumeration();
+        int browsedMessage = 0;
+        while (msgs.hasMoreElements()) {
+            browsedMessage++;
+            msgs.nextElement();
+        }
+        System.out.println(browsedMessage);
+    }
+
+    public void setUp() throws Exception {
+        super.setAutoFail(true);
+        super.setUp();
+        createBroker(new URI(
+                "broker:(tcp://localhost:61616)/BrokerA?persistent=false&useJmx=false"));
+        createBroker(new URI(
+                "broker:(tcp://localhost:61617)/BrokerB?persistent=false&useJmx=false"));
+    }
+
+}



Mime
View raw message