activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1300726 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/transport/failover/FailoverTransport.java test/java/org/apache/activemq/transport/failover/ConnectionHangOnStartupTest.java
Date Wed, 14 Mar 2012 21:31:26 GMT
Author: tabish
Date: Wed Mar 14 21:31:25 2012
New Revision: 1300726

URL: http://svn.apache.org/viewvc?rev=1300726&view=rev
Log:
fix and test for: https://issues.apache.org/jira/browse/AMQ-3719

Added:
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/failover/ConnectionHangOnStartupTest.java
  (with props)
Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java?rev=1300726&r1=1300725&r2=1300726&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
Wed Mar 14 21:31:25 2012
@@ -612,6 +612,13 @@ public class FailoverTransport implement
                                 // Rethrow the exception so it will handled by
                                 // the outer catch
                                 throw e;
+                            } else {
+                                // Handle the error but allow the method to return since
the
+                                // tracked commands are replayed on reconnect.
+                                if (LOG.isDebugEnabled()) {
+                                    LOG.debug("Send oneway attempt: " + i + " failed for
command:" + command);
+                                }
+                                handleTransportFailure(e);
                             }
                         }
 

Added: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/failover/ConnectionHangOnStartupTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/failover/ConnectionHangOnStartupTest.java?rev=1300726&view=auto
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/failover/ConnectionHangOnStartupTest.java
(added)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/failover/ConnectionHangOnStartupTest.java
Wed Mar 14 21:31:25 2012
@@ -0,0 +1,109 @@
+/**
+ * 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.transport.failover;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicReference;
+
+import javax.jms.Connection;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.xbean.BrokerFactoryBean;
+import org.junit.After;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.core.io.ClassPathResource;
+
+/**
+ * Tests for AMQ-3719
+ */
+public class ConnectionHangOnStartupTest {
+
+    private static final Logger LOG = LoggerFactory.getLogger(ConnectionHangOnStartupTest.class);
+
+    // short maxInactivityDurationInitalDelay to trigger the bug, short
+    // maxReconnectDelay so that the test runs faster (because it will retry
+    // connection sooner)
+    protected String uriString = "failover://(tcp://localhost:62001?wireFormat.maxInactivityDurationInitalDelay=1,tcp://localhost:62002?wireFormat.maxInactivityDurationInitalDelay=1)?randomize=false&maxReconnectDelay=200";
+    protected BrokerService master = null;
+    protected AtomicReference<BrokerService> slave = new AtomicReference<BrokerService>();
+
+    @After
+    public void tearDown() throws Exception {
+
+        BrokerService brokerService = slave.get();
+        if (brokerService != null) {
+            brokerService.stop();
+        }
+        if (master != null)
+            master.stop();
+    }
+
+    protected ActiveMQConnectionFactory createConnectionFactory() throws Exception {
+        return new ActiveMQConnectionFactory(uriString);
+    }
+
+    protected void createMaster() throws Exception {
+        BrokerFactoryBean brokerFactory = new BrokerFactoryBean(new ClassPathResource(getMasterXml()));
+        brokerFactory.afterPropertiesSet();
+        master = brokerFactory.getBroker();
+        master.start();
+    }
+
+    protected void createSlave() throws Exception {
+        BrokerFactoryBean brokerFactory = new BrokerFactoryBean(new ClassPathResource(getSlaveXml()));
+        brokerFactory.afterPropertiesSet();
+        BrokerService broker = brokerFactory.getBroker();
+        broker.start();
+        slave.set(broker);
+    }
+
+    protected String getSlaveXml() {
+        return "org/apache/activemq/broker/ft/slave.xml";
+    }
+
+    protected String getMasterXml() {
+        return "org/apache/activemq/broker/ft/master.xml";
+    }
+
+    @Test(timeout=60000)
+    public void testInitialWireFormatNegotiationTimeout() throws Exception {
+        final AtomicReference<Connection> conn = new AtomicReference<Connection>();
+        final CountDownLatch connStarted = new CountDownLatch(1);
+
+        Thread t = new Thread() {
+            @Override
+            public void run() {
+                try {
+                    conn.set(createConnectionFactory().createConnection());
+                    conn.get().start();
+                } catch (Exception ex) {
+                    LOG.error("could not create or start connection", ex);
+                }
+                connStarted.countDown();
+            }
+        };
+        t.start();
+        createMaster();
+        createSlave();
+
+        conn.get().stop();
+    }
+
+}

Propchange: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/failover/ConnectionHangOnStartupTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message