activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject svn commit: r701477 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/transport/tcp/ test/java/org/apache/activemq/network/ test/java/org/apache/activemq/transport/tcp/
Date Fri, 03 Oct 2008 18:18:38 GMT
Author: gtully
Date: Fri Oct  3 11:18:38 2008
New Revision: 701477

URL: http://svn.apache.org/viewvc?rev=701477&view=rev
Log:
fix AMQ-1967, server side transport options are now respected, it is possible to configure
a broker connector url like tcp://localhost:61617?transport.reuseAddress=true etc

Added:
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/tcp/TcpTransportBindTest.java
  (with props)
Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/tcp/TcpTransportServer.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/network/DuplexNetworkMBeanTest.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/tcp/TcpTransportServer.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/tcp/TcpTransportServer.java?rev=701477&r1=701476&r2=701477&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/tcp/TcpTransportServer.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/tcp/TcpTransportServer.java
Fri Oct  3 11:18:38 2008
@@ -21,6 +21,7 @@
 import java.net.InetSocketAddress;
 import java.net.ServerSocket;
 import java.net.Socket;
+import java.net.SocketException;
 import java.net.SocketTimeoutException;
 import java.net.URI;
 import java.net.URISyntaxException;
@@ -42,6 +43,7 @@
 import org.apache.activemq.transport.TransportServer;
 import org.apache.activemq.transport.TransportServerThreadSupport;
 import org.apache.activemq.util.IOExceptionSupport;
+import org.apache.activemq.util.IntrospectionSupport;
 import org.apache.activemq.util.ServiceListener;
 import org.apache.activemq.util.ServiceStopper;
 import org.apache.activemq.util.ServiceSupport;
@@ -133,7 +135,8 @@
             } else {
                 this.serverSocket = serverSocketFactory.createServerSocket(bind.getPort(),
backlog, addr);
             }
-            this.serverSocket.setSoTimeout(2000);
+            configureServerSocket(this.serverSocket);
+            
         } catch (IOException e) {
             throw IOExceptionSupport.create("Failed to bind to server socket: " + bind +
" due to: " + e, e);
         }
@@ -153,6 +156,11 @@
         }
     }
 
+    private void configureServerSocket(ServerSocket socket) throws SocketException {
+        socket.setSoTimeout(2000);
+        IntrospectionSupport.setProperties(socket, transportOptions);
+    }
+
     /**
      * @return Returns the wireFormatFactory.
      */

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/network/DuplexNetworkMBeanTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/network/DuplexNetworkMBeanTest.java?rev=701477&r1=701476&r2=701477&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/network/DuplexNetworkMBeanTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/network/DuplexNetworkMBeanTest.java
Fri Oct  3 11:18:38 2008
@@ -34,12 +34,12 @@
 public class DuplexNetworkMBeanTest extends TestCase {
 
     protected static final Log LOG = LogFactory.getLog(DuplexNetworkMBeanTest.class);
-    protected final int numRestarts = 10;
+    protected final int numRestarts = 5;
 
     protected BrokerService createBroker() throws Exception {
         BrokerService broker = new BrokerService();
         broker.setBrokerName("broker");
-        broker.addConnector("tcp://localhost:61617");
+        broker.addConnector("tcp://localhost:61617?transport.reuseAddress=true");
         
         return broker;
     }
@@ -47,8 +47,8 @@
     protected BrokerService createNetworkedBroker() throws Exception {
         BrokerService broker = new BrokerService();
         broker.setBrokerName("networkedBroker");
-        broker.addConnector("tcp://localhost:62617");
-        NetworkConnector networkConnector = broker.addNetworkConnector("static:(tcp://localhost:61617)?maxReconnectDelay=1000&useExponentialBackOff=false");
+        broker.addConnector("tcp://localhost:62617?transport.reuseAddress=true");
+        NetworkConnector networkConnector = broker.addNetworkConnector("static:(tcp://localhost:61617?wireFormat.maxInactivityDuration=500)?useExponentialBackOff=false");
         networkConnector.setDuplex(true);
         return broker;
     }
@@ -87,11 +87,12 @@
         for (int i=0; i<numRestarts; i++) {
             broker = createBroker();
             broker.start();
-            assertEquals(1, countMbeans(networkedBroker, "NetworkBridge", 10000));
-            assertEquals(1, countMbeans(broker, "Connection"));
+            assertEquals(1, countMbeans(networkedBroker, "NetworkBridge", 5000));
+            assertEquals("restart number: " + i, 1, countMbeans(broker, "Connection", 10000));
             
             broker.stop();
             broker.waitUntilStopped();
+            assertEquals(0, countMbeans(broker, "stopped"));
         }
         
         assertEquals(0, countMbeans(networkedBroker, "NetworkBridge"));

Added: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/tcp/TcpTransportBindTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/tcp/TcpTransportBindTest.java?rev=701477&view=auto
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/tcp/TcpTransportBindTest.java
(added)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/tcp/TcpTransportBindTest.java
Fri Oct  3 11:18:38 2008
@@ -0,0 +1,40 @@
+/**
+ * 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.tcp;
+
+import javax.jms.Connection;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.EmbeddedBrokerTestSupport;
+
+public class TcpTransportBindTest extends EmbeddedBrokerTestSupport {
+    final String addr = "tcp://localhost:61617";
+    
+    /**
+     * exercise some server side socket options
+     * @throws Exception
+     */
+    protected void setUp() throws Exception {   
+        bindAddress = addr + "?transport.reuseAddress=true&transport.soTimeout=1000";
+        super.setUp();
+    }
+    
+    public void testConnect() throws Exception {
+        Connection connection = new ActiveMQConnectionFactory(addr).createConnection();
+        connection.start();
+    }
+}

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

Propchange: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/tcp/TcpTransportBindTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



Mime
View raw message