Hi folks,

Until now I had only implemented server apps with MINA (IoAcceptor), and no
client apps (IoConnector).

I started working on a small tutorial about ProtocolDecoder/ProtocolEncoder
to complement Mark's Getting Started Guide,
and while implementing the client side I was wondering if a ReadFuture would
be an interesting feauture.

Suppose you have a request-response protocol and you want to implement the
client synchronously:
connect, send a request and wait until the response comes in.

What is currently the best way to go ?

With a ReadFuture it could be done like this:

   Object request = ...;
   ConnectFuture connectFuture = connector.connect(new
InetSocketAddress("localhost",5555));
   connectFuture.join(100);
   if (connectFuture.isConnected()) {
     IoSession session = connectFuture.getSession();
     session.write( request );
     ReadFuture readFuture = session.read();
     readFuture.join();
     if (readFuture.messageRead()) {
       Object response = readFuture.getResult();
       doSomethingWith(response);
     }
     session.close().join();
   }

What do you think ?

Maarten

On 4/12/07, Trustin Lee <[EMAIL PROTECTED]> wrote:

Hi folks,

Today, I added a new feature to the trunk.  The issue has been filed
since the early days of MINA, but we didn't give it high priority
because it was a good-to-have feature.  I apologize those who wait for
this issue to be resolved for a long time.

The Request-Response filter is very useful for a client application
that deals with a request-response protocol.  Please refer to my last
comment of the following JIRA page for the detailed explanation and
example:

https://issues.apache.org/jira/browse/DIRMINA-92#action_12488311

Any questions and additional feature request on this filter are welcome.

Trustin
--
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6

Reply via email to