Erratic message reception when more than 1 client
wiradikusuma
wiradikusuma at gmail.com
Wed Jan 13 06:25:11 EST 2010
Hi guys,
I'm experiencing erratic message reception when there are more than one
client connected to my Netty-based TCP server.
The client is a dummy MINA client sending 1KB XML string 5000 times:
-- client ----------------------------------------------
for 1 to 5000 { session.write(something) }
--------------------------------------------------------
The server looks like this:
-- Spring ----------------------------------------------
<bean id="executor" class="...ThreadPoolTaskExecutor" scope="prototype">
<property name="corePoolSize" value="10"/>
<property name="maxPoolSize" value="5000"/>
</bean>
--------------------------------------------------------
-- connection initiation -------------------------------
ChannelFactory cf = new OioServerSocketChannelFactory(executor, executor);
ServerBootstrap bootstrap = new ServerBootstrap(cf);
ChannelPipeline pipeline = bootstrap.getPipeline();
pipeline.addLast("framer", new DelimiterBasedFrameDecoder(8192,
Delimiters.lineDelimiter()));
pipeline.addLast("decoder", new StringDecoder());
pipeline.addLast("encoder", new StringEncoder());
pipeline.addLast("handler", clientHandler);
bootstrap.setOption("child.tcpNoDelay", true);
bootstrap.setOption("child.keepAlive", true);
bootstrap.setOption("reuseAddress", true);
bootstrap.bind(new InetSocketAddress(serverPort));
--------------------------------------------------------
-- handler ---------------------------------------------
@ChannelPipelineCoverage("all")
class ClientHandler extends SimpleChannelHandler {
channelConnected(...) {
ctx.setAttachment(new ClientXml());
}
messageReceived(...) {
Channel channel = event.getChannel();
ClientXml data = (ClientXml) context.getAttachment();
data.addXmlPart((String) event.getMessage());
final String xml = data.getNextXML();
if (xml != null) {
executor.execute(new Runnable() {
public void run() {
// do something useful
}
}
}
}
--------------------------------------------------------
When only one client connected to the server, everything is OK.
All messages received correctly, all XMLs logged correctly.
But when there are more than one, my log starts to look like this:
--------------------------------------------------------
<?xml version='1.0' encoding='UTF-8' standalone='yes'?> <?xml version='1.0'
encoding='UTF-8' standalone='yes'?> <?xml version='1.0' encoding='UTF-8'
standalone='yes'?> <?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<?xml version='1.0' encoding='UTF-8' standalone='yes'?> <?xml version='1.0'
encoding='UTF-8' standalone='yes'?> <?xml version='1.0' encoding='UTF-8'
standalone='yes'?> <?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<?xml version='1.0' encoding='UTF-8' standalone='yes'?> <?xml version='1.0'
encoding='UTF-8' standalone='yes'?> <?xml version='1.0' encoding='UTF-8'
standalone='yes'?> <?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<?xml version='1.0' encoding='UTF-8' standalone='yes'?> <?xml version='1.0'
encoding='UTF-8' standalone='yes'?> <?xml version='1.0' encoding='UTF-8'
standalone='yes'?> <?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<?xml version='1.0' encoding='UTF-8' standalone='yes'?> <?xml version='1.0'
encoding='UTF-8' standalone='yes'?> <?xml version='1.0' encoding='UTF-8'
standalone='yes'?> <?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<?xml version='1.0' encoding='UTF-8' standalone='yes'?> <?xml version='1.0'
encoding='UTF-8' standalone='yes'?> <?xml version='1.0' encoding='UTF-8'
standalone='yes'?> <?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<?xml version='1.0' encoding='UTF-8' standalone='yes'?> <?xml version='1.0'
encoding='UTF-8' standalone='yes'?> <?xml version='1.0' encoding='UTF-8'
standalone='yes'?> ... continue until unlimited
--------------------------------------------------------
Any idea what happens and what should I do?
--
View this message in context: http://n2.nabble.com/Erratic-message-reception-when-more-than-1-client-tp4343987p4343987.html
Sent from the Netty User Group mailing list archive at Nabble.com.
More information about the netty-users
mailing list