java - Identify if the session is idle and flush in Decoder with Mina? -


i using apache camel in conjunction apache mina have tcp server. using specific protocol decoder in code. in decoder, waiting x amount of bytes before send them downstream route.

i implement able understand session got idle or closed , send bytes have got downstream route (it doesn't matter if didn't total x bytes). have tried implementing iofilteradapter overriding method sessionidle() not sure how use it.

overriding sessionidle() method closing (or configuring want) session when session idle time has been reached.

you can set idle time inside handler class (or extending iofilteradapter ) overriding sessionopened() method. should work:

@override public void sessionopened(final iosession session) throws exception {     session.getconfig().setidletime(idlestatus.both_idle, this.idletimeout); } 

you can use other idle states defined in idlestatus class. there there states:

public static final idlestatus reader_idle = new idlestatus("reader idle"); public static final idlestatus writer_idle = new idlestatus("writer idle"); public static final idlestatus both_idle = new idlestatus("both idle"); 

Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -