You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by bs...@apache.org on 2009/06/30 19:52:12 UTC

svn commit: r789851 - in /activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/tcp: ExceededMaximumConnectionsException.java TcpTransportServer.java

Author: bsnyder
Date: Tue Jun 30 17:52:12 2009
New Revision: 789851

URL: http://svn.apache.org/viewvc?rev=789851&view=rev
Log:
Added a better exception and error message for exceeding the maximumConnections - AMQ-1928

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

Added: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/tcp/ExceededMaximumConnectionsException.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/tcp/ExceededMaximumConnectionsException.java?rev=789851&view=auto
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/tcp/ExceededMaximumConnectionsException.java (added)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/tcp/ExceededMaximumConnectionsException.java Tue Jun 30 17:52:12 2009
@@ -0,0 +1,22 @@
+package org.apache.activemq.transport.tcp;
+
+/**
+ * Thrown to indicate that the {@link TcpTransportServer#maximumConnections} 
+ * property has been exceeded. 
+ * 
+ * @see {@link TcpTransportServer#maximumConnections}
+ * @author bsnyder
+ *
+ */
+public class ExceededMaximumConnectionsException extends Exception {
+
+    /**
+     * Default serial version id for serialization
+     */
+    private static final long serialVersionUID = -1166885550766355524L;
+
+    public ExceededMaximumConnectionsException(String message) {
+        super(message);
+    }
+
+}

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

Propchange: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/tcp/ExceededMaximumConnectionsException.java
------------------------------------------------------------------------------
    svn:keywords = Id Revision

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=789851&r1=789850&r2=789851&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 Tue Jun 30 17:52:12 2009
@@ -394,34 +394,38 @@
     protected final void handleSocket(Socket socket) {
         try {
             if (this.currentTransportCount >= this.maximumConnections) {
+                throw new ExceededMaximumConnectionsException("Exceeded the maximum " + 
+                    "number of allowed client connections. See the 'maximumConnections' " + 
+                    "property on the TCP transport configuration URI in the ActiveMQ " + 
+                    "configuration file (e.g., activemq.xml)"); 
                 
-            }else {
-            HashMap<String, Object> options = new HashMap<String, Object>();
-            options.put("maxInactivityDuration", Long
-                    .valueOf(maxInactivityDuration));
-            options.put("maxInactivityDurationInitalDelay", Long
-                    .valueOf(maxInactivityDurationInitalDelay));            
-            options.put("minmumWireFormatVersion", Integer
-                    .valueOf(minmumWireFormatVersion));
-            options.put("trace", Boolean.valueOf(trace));
-            options.put("soTimeout", Integer.valueOf(soTimeout));
-            options.put("socketBufferSize", Integer.valueOf(socketBufferSize));
-            options.put("connectionTimeout", Integer.valueOf(connectionTimeout));
-            options.put("logWriterName", logWriterName);
-            options
-                    .put("dynamicManagement", Boolean
-                            .valueOf(dynamicManagement));
-            options.put("startLogging", Boolean.valueOf(startLogging));
-
-            options.putAll(transportOptions);
-            WireFormat format = wireFormatFactory.createWireFormat();
-            Transport transport = createTransport(socket, format);
-            if (transport instanceof ServiceSupport) {
-                ((ServiceSupport) transport).addServiceListener(this);
-            }
-            Transport configuredTransport = transportFactory.serverConfigure(
-                    transport, format, options);
-            getAcceptListener().onAccept(configuredTransport);
+            } else {
+                HashMap<String, Object> options = new HashMap<String, Object>();
+                options.put("maxInactivityDuration", Long.valueOf(maxInactivityDuration));
+                options.put("maxInactivityDurationInitalDelay", 
+                    Long.valueOf(maxInactivityDurationInitalDelay));
+                options.put("minmumWireFormatVersion", 
+                    Integer.valueOf(minmumWireFormatVersion));
+                options.put("trace", Boolean.valueOf(trace));
+                options.put("soTimeout", Integer.valueOf(soTimeout));
+                options.put("socketBufferSize", Integer.valueOf(socketBufferSize));
+                options.put("connectionTimeout", Integer.valueOf(connectionTimeout));
+                options.put("logWriterName", logWriterName);
+                options.put("dynamicManagement", Boolean.valueOf(dynamicManagement));
+                options.put("startLogging", Boolean.valueOf(startLogging));
+                options.putAll(transportOptions);
+
+                WireFormat format = wireFormatFactory.createWireFormat();
+                Transport transport = createTransport(socket, format);
+
+                if (transport instanceof ServiceSupport) {
+                    ((ServiceSupport) transport).addServiceListener(this);
+                }
+
+                Transport configuredTransport = 
+                    transportFactory.serverConfigure( transport, format, options);
+
+                getAcceptListener().onAccept(configuredTransport);
             }
         } catch (SocketTimeoutException ste) {
             // expect this to happen
@@ -482,4 +486,4 @@
     public void stopped(Service service) {
         this.currentTransportCount--;
     }
-}
\ No newline at end of file
+}