mirror of https://github.com/apache/activemq.git
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@660906 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7d87837e08
commit
92604947a5
|
@ -63,6 +63,7 @@ public class TcpTransportServer extends TransportServerThreadSupport {
|
||||||
protected final TcpTransportFactory transportFactory;
|
protected final TcpTransportFactory transportFactory;
|
||||||
protected long maxInactivityDuration = 30000;
|
protected long maxInactivityDuration = 30000;
|
||||||
protected int minmumWireFormatVersion;
|
protected int minmumWireFormatVersion;
|
||||||
|
protected boolean useQueueForAccept=true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* trace=true -> the Transport stack where this TcpTransport
|
* trace=true -> the Transport stack where this TcpTransport
|
||||||
|
@ -210,6 +211,35 @@ public class TcpTransportServer extends TransportServerThreadSupport {
|
||||||
public void setStartLogging(boolean startLogging) {
|
public void setStartLogging(boolean startLogging) {
|
||||||
this.startLogging = startLogging;
|
this.startLogging = startLogging;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the backlog
|
||||||
|
*/
|
||||||
|
public int getBacklog() {
|
||||||
|
return backlog;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param backlog the backlog to set
|
||||||
|
*/
|
||||||
|
public void setBacklog(int backlog) {
|
||||||
|
this.backlog = backlog;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the useQueueForAccept
|
||||||
|
*/
|
||||||
|
public boolean isUseQueueForAccept() {
|
||||||
|
return useQueueForAccept;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param useQueueForAccept the useQueueForAccept to set
|
||||||
|
*/
|
||||||
|
public void setUseQueueForAccept(boolean useQueueForAccept) {
|
||||||
|
this.useQueueForAccept = useQueueForAccept;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pull Sockets from the ServerSocket
|
* pull Sockets from the ServerSocket
|
||||||
|
@ -223,7 +253,11 @@ public class TcpTransportServer extends TransportServerThreadSupport {
|
||||||
if (isStopped() || getAcceptListener() == null) {
|
if (isStopped() || getAcceptListener() == null) {
|
||||||
socket.close();
|
socket.close();
|
||||||
} else {
|
} else {
|
||||||
socketQueue.put(socket);
|
if (useQueueForAccept) {
|
||||||
|
socketQueue.put(socket);
|
||||||
|
}else {
|
||||||
|
handleSocket(socket);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (SocketTimeoutException ste) {
|
} catch (SocketTimeoutException ste) {
|
||||||
|
@ -274,33 +308,36 @@ public class TcpTransportServer extends TransportServerThreadSupport {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void doStart() throws Exception {
|
protected void doStart() throws Exception {
|
||||||
Runnable run = new Runnable() {
|
if(useQueueForAccept) {
|
||||||
public void run() {
|
Runnable run = new Runnable() {
|
||||||
try {
|
public void run() {
|
||||||
while (!isStopped() && !isStopping()) {
|
try {
|
||||||
Socket sock = socketQueue.poll(1, TimeUnit.SECONDS);
|
while (!isStopped() && !isStopping()) {
|
||||||
if (sock != null) {
|
Socket sock = socketQueue.poll(1, TimeUnit.SECONDS);
|
||||||
handleSocket(sock);
|
if (sock != null) {
|
||||||
|
handleSocket(sock);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
LOG.info("socketQueue interuppted - stopping");
|
||||||
|
if (!isStopping()) {
|
||||||
|
onAcceptError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
LOG.info("socketQueue interuppted - stopping");
|
|
||||||
if (!isStopping()) {
|
|
||||||
onAcceptError(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
};
|
||||||
|
socketHandlerThread = new Thread(null, run,
|
||||||
};
|
"ActiveMQ Transport Server Thread Handler: " + toString(),
|
||||||
socketHandlerThread = new Thread(null, run,
|
getStackSize());
|
||||||
"ActiveMQ Transport Server Thread Handler: " + toString(),
|
socketHandlerThread.setDaemon(true);
|
||||||
getStackSize());
|
socketHandlerThread.setPriority(ThreadPriorities.BROKER_MANAGEMENT-1);
|
||||||
socketHandlerThread.setDaemon(true);
|
socketHandlerThread.start();
|
||||||
socketHandlerThread.setPriority(ThreadPriorities.BROKER_MANAGEMENT-1);
|
}
|
||||||
super.doStart();
|
super.doStart();
|
||||||
socketHandlerThread.start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void doStop(ServiceStopper stopper) throws Exception {
|
protected void doStop(ServiceStopper stopper) throws Exception {
|
||||||
|
@ -348,7 +385,5 @@ public class TcpTransportServer extends TransportServerThreadSupport {
|
||||||
onAcceptError(e);
|
onAcceptError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue