Added a better exception and error message for exceeding the maximumConnections - AMQ-1928

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@789851 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Bruce Snyder 2009-06-30 17:52:12 +00:00
parent 22422ac5de
commit 0f1907138b
2 changed files with 53 additions and 27 deletions

View File

@ -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);
}
}

View File

@ -394,34 +394,38 @@ public class TcpTransportServer extends TransportServerThreadSupport implements
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));
} 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);
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);
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 class TcpTransportServer extends TransportServerThreadSupport implements
public void stopped(Service service) {
this.currentTransportCount--;
}
}
}