Is there a way to cache TCP session (SocketConnector session) until some
expiration delay times out so as to be able to reuse TCP connection instead
of creating a new one each time? Is there a mechanism like IoSessionRecycler
for TCP session in mina 1.1.x?
Thanks for the info.
To help the discussion, I am currently connecting with the server like in
the following, so how can I reuse my connection (and I assume, my session)
instead of creating a new one each time.
public void send(final T payload, InetSocketAddress destination, IoHandler
responseHandler)
{
if(payload == null || destination == null || responseHandler ==
null)
{
throw new IllegalArgumentException("You must provide
valid, non null
arguments to the method send()");
}
System.out.println("sending message as ByteBuffer");
SocketConnector connector = new SocketConnector();
connector.setDefaultConfig(connectorConfig);
ConnectFuture connFuture = connector.connect(destination,
responseHandler);
connFuture.addListener(new IoFutureListener() {
public void operationComplete(IoFuture future) {
ConnectFuture connFuture = (ConnectFuture)
future;
if (connFuture.isConnected()) {
IoSession session = future.getSession();
try {
System.out.println("writing
message to session");
session.write(payload);
session.close();
System.out.println("writing
done, session close");
} catch (Exception e) {
System.err.println("Encountered
problem while writing ByteBuffer to
session");
e.printStackTrace();
}
} else {
System.err.println("Connection attempt
failed...exiting");
}
}
});
}
Simon
--
View this message in context:
http://www.nabble.com/How-to-SocketConnector---IoSessionRecycler-tf4779666s16868.html#a13673734
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.