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) { protected final void handleSocket(Socket socket) {
try { try {
if (this.currentTransportCount >= this.maximumConnections) { 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 { } else {
HashMap<String, Object> options = new HashMap<String, Object>(); HashMap<String, Object> options = new HashMap<String, Object>();
options.put("maxInactivityDuration", Long options.put("maxInactivityDuration", Long.valueOf(maxInactivityDuration));
.valueOf(maxInactivityDuration)); options.put("maxInactivityDurationInitalDelay",
options.put("maxInactivityDurationInitalDelay", Long Long.valueOf(maxInactivityDurationInitalDelay));
.valueOf(maxInactivityDurationInitalDelay)); options.put("minmumWireFormatVersion",
options.put("minmumWireFormatVersion", Integer Integer.valueOf(minmumWireFormatVersion));
.valueOf(minmumWireFormatVersion)); options.put("trace", Boolean.valueOf(trace));
options.put("trace", Boolean.valueOf(trace)); options.put("soTimeout", Integer.valueOf(soTimeout));
options.put("soTimeout", Integer.valueOf(soTimeout)); options.put("socketBufferSize", Integer.valueOf(socketBufferSize));
options.put("socketBufferSize", Integer.valueOf(socketBufferSize)); options.put("connectionTimeout", Integer.valueOf(connectionTimeout));
options.put("connectionTimeout", Integer.valueOf(connectionTimeout)); options.put("logWriterName", logWriterName);
options.put("logWriterName", logWriterName); options.put("dynamicManagement", Boolean.valueOf(dynamicManagement));
options options.put("startLogging", Boolean.valueOf(startLogging));
.put("dynamicManagement", Boolean options.putAll(transportOptions);
.valueOf(dynamicManagement));
options.put("startLogging", Boolean.valueOf(startLogging));
options.putAll(transportOptions); WireFormat format = wireFormatFactory.createWireFormat();
WireFormat format = wireFormatFactory.createWireFormat(); Transport transport = createTransport(socket, format);
Transport transport = createTransport(socket, format);
if (transport instanceof ServiceSupport) { if (transport instanceof ServiceSupport) {
((ServiceSupport) transport).addServiceListener(this); ((ServiceSupport) transport).addServiceListener(this);
} }
Transport configuredTransport = transportFactory.serverConfigure(
transport, format, options); Transport configuredTransport =
getAcceptListener().onAccept(configuredTransport); transportFactory.serverConfigure( transport, format, options);
getAcceptListener().onAccept(configuredTransport);
} }
} catch (SocketTimeoutException ste) { } catch (SocketTimeoutException ste) {
// expect this to happen // expect this to happen
@ -482,4 +486,4 @@ public class TcpTransportServer extends TransportServerThreadSupport implements
public void stopped(Service service) { public void stopped(Service service) {
this.currentTransportCount--; this.currentTransportCount--;
} }
} }