Any way to re-use the Channel..
Wesly smith
weslysmith0 at gmail.com
Thu Dec 18 01:09:27 EST 2008
It could be dummy question ...
I tried to cache and re-use the channels in http case.
Is there any way to achieve that?
Currently, the way I am doing roughly is:
===================
// first time, I getChannel from future.
Channel c = future.getChannel();
...
c.write(httpMsg);
// cache the channels
cachedChannels.appendChannel();
...
// then in the messageReceived()
// It seems I have to disconnect(), otherwise, the transaction wont finish.
event.getChannel().disconnect();
// later I want to re-use the channel and get this channel from cache.
Channel ch = cachedChannels.getFreeChannel();
if (ch.isConnected() == false)
{
future = ch.connect(address);
}
But I got ClosedChannelException:
NioClientSocketChannel(id: 48a7cec7-011e-1000-b33c-018557bf3f5e) - (cause:
ClosedChannelException) java.nio.channels.ClosedChannelException
at
sun.nio.ch.SocketChannelImpl.ensureOpenAndUnconnected(SocketChannelImpl.java:472)
at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:486)
at
org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink.connect(NioClientSocketPipelineSink.java:143)
at
org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink.eventSunk(NioClientSocketPipelineSink.java:108)
at org.jboss.netty.channel.Channels.connect(Channels.java:554)
at
org.jboss.netty.channel.AbstractChannel.connect(AbstractChannel.java:166)
====
Any idea or suggestion about re-use the Channel? I hope it will give me some
performance advantage.
--
View this message in context: http://n2.nabble.com/Any-way-to-re-use-the-Channel..-tp1671789p1671789.html
Sent from the Netty User Group mailing list archive at Nabble.com.
More information about the netty-users
mailing list