0
从我所了解的(如果我错了,请纠正我),在tomcat中按顺序处理传入的websocket消息。这意味着如果您在一个websocket中有100个传入消息,它们将仅使用从消息1到消息100的一个线程逐个进行处理。在tomcat中使用多线程处理websocket消息消息
但这不适用于我。我需要在websocket中同时处理传入的消息以增加我的websocket吞吐量。进入的消息不依赖于彼此,因此不需要按顺序处理。
问题是如何配置tomcat,以便它可以为每个websocket分配多个工作线程以同时处理传入的消息?
任何提示表示赞赏。
这是在tomcat code,我认为这是每个WebSocket连接阻塞(这是有道理的):
/**
* Called when there is data in the ServletInputStream to process.
*
* @throws IOException if an I/O error occurs while processing the available
* data
*/
public void onDataAvailable() throws IOException {
synchronized (connectionReadLock) {
while (isOpen() && sis.isReady()) {
// Fill up the input buffer with as much data as we can
int read = sis.read(
inputBuffer, writePos, inputBuffer.length - writePos);
if (read == 0) {
return;
}
if (read == -1) {
throw new EOFException();
}
writePos += read;
processInputBuffer();
}
}
}