You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@mina.apache.org by Simon Trudeau <st...@bluetreewireless.com> on 2008/05/31 00:32:11 UTC
[Q] Statefull session reconnection
I have implemented reconnection in an IoFilter like the following:
filterClose(Session session...) {
IoConnector connector = (IoConnector)session.getService();
InetSocketAddress remoteAddress =
(InetSocketAddress)session.getAttribute("session.remoteAddress");
ConnectFuture future = connector.connect(remoteAddress, new
ClientSessionInitializer(session));
ConnectFuture future2 = future.awaitUninterruptibly();
if(future2.isConnected())
{
IoSession newSession = future2.getSession();
...
}
...
}
Yet somehow, usually on windows xp single core machine, it seems that my
previous session is still up and doesn't get garbaged collected.
Is there a way to reuse my previous session object when reconnecting or
do I have to create a new session like I did?
Are the two session objects independent or are they still "linked"
together? Does it make a different if I obtain the connector from
session.getService() or if I use call my global instance?
I would really like to know how to properly do reconnection and most
importantly, statefull reconnection.
Thanks,
Simon
RE: [Q] Statefull session reconnection
Posted by Simon Trudeau <st...@bluetreewireless.com>.
Thanks Niklas, it seems that forwarding the filterClose() event did the
trick. Thanks.
Simon
-----Original Message-----
From: Niklas Therning [mailto:niklas@trillian.se]
Sent: June-02-08 2:27 AM
To: users@mina.apache.org
Subject: Re: [Q] Statefull session reconnection
I think your code looks ok. Some things that come to mind:
* You need to foward the filterClose() call to the nextFilter otherwise
your old session won't be closed.
* MINA will call sessionClosed() for the old session so your filter
needs to intercept that event and hide it from the filters and the
handler after your reconnect filter.
* You might want to hide the sessionCreated() and sessionOpened() events
for the new session as well.
This JIRA issue may be of interest to you:
https://issues.apache.org/jira/browse/DIRMINA-68. There's a patch
attached there for a reconnect filter. I don't know if it does what you
want. Maybe it can be adapted to your needs?
HTH
/Niklas
Simon Trudeau skrev:
> I have implemented reconnection in an IoFilter like the following:
>
> filterClose(Session session...) {
>
> IoConnector connector = (IoConnector)session.getService();
> InetSocketAddress remoteAddress =
> (InetSocketAddress)session.getAttribute("session.remoteAddress");
>
> ConnectFuture future = connector.connect(remoteAddress, new
> ClientSessionInitializer(session));
> ConnectFuture future2 = future.awaitUninterruptibly();
>
> if(future2.isConnected())
> {
> IoSession newSession = future2.getSession(); ...
> }
> ...
> }
>
> Yet somehow, usually on windows xp single core machine, it seems that
> my previous session is still up and doesn't get garbaged collected.
>
> Is there a way to reuse my previous session object when reconnecting
> or do I have to create a new session like I did?
> Are the two session objects independent or are they still "linked"
> together? Does it make a different if I obtain the connector from
> session.getService() or if I use call my global instance?
>
> I would really like to know how to properly do reconnection and most
> importantly, statefull reconnection.
>
> Thanks,
>
> Simon
>
>
>
Re: [Q] Statefull session reconnection
Posted by Niklas Therning <ni...@trillian.se>.
I think your code looks ok. Some things that come to mind:
* You need to foward the filterClose() call to the nextFilter otherwise
your old session won't be closed.
* MINA will call sessionClosed() for the old session so your filter
needs to intercept that event and hide it from the filters and the
handler after your reconnect filter.
* You might want to hide the sessionCreated() and sessionOpened() events
for the new session as well.
This JIRA issue may be of interest to you:
https://issues.apache.org/jira/browse/DIRMINA-68. There's a patch
attached there for a reconnect filter. I don't know if it does what you
want. Maybe it can be adapted to your needs?
HTH
/Niklas
Simon Trudeau skrev:
> I have implemented reconnection in an IoFilter like the following:
>
> filterClose(Session session...) {
>
> IoConnector connector = (IoConnector)session.getService();
> InetSocketAddress remoteAddress =
> (InetSocketAddress)session.getAttribute("session.remoteAddress");
>
> ConnectFuture future = connector.connect(remoteAddress, new
> ClientSessionInitializer(session));
> ConnectFuture future2 = future.awaitUninterruptibly();
>
> if(future2.isConnected())
> {
> IoSession newSession = future2.getSession();
> ...
> }
> ...
> }
>
> Yet somehow, usually on windows xp single core machine, it seems that my
> previous session is still up and doesn't get garbaged collected.
>
> Is there a way to reuse my previous session object when reconnecting or
> do I have to create a new session like I did?
> Are the two session objects independent or are they still "linked"
> together? Does it make a different if I obtain the connector from
> session.getService() or if I use call my global instance?
>
> I would really like to know how to properly do reconnection and most
> importantly, statefull reconnection.
>
> Thanks,
>
> Simon
>
>
>