Matching responses to requests with a Future?

37 views
Skip to first unread message

Rogan Dawes

unread,
Aug 23, 2017, 11:00:51 AM8/23/17
to Netty discussions
Hi,

I'm trying to come up with a scheme to match responses to the original request, and trigger a Future/Promise when the response is received.

Conceptually, something like:

Message m = new Message("Something");
Future<Response> rf = m.future();
rf.addListener(new FutureListener() {
  public void operationComplete(Future<Response> f) {
    if (f.isSuccess()) {
      Response r = f.get();
      // ... something with the response
    } else {
      // it failed
    }
  }
});
ctx.writeAndFlush(m);

A ChannelHandler further along the pipeline will take care of matching the responses to the requests, and will trigger the future accordingly.

I'm actually trying to implement a Modem handler, that will indicate whether the AT command was successfully executed or not, in case that helps add context.

Any thoughts?

Rogan

Rogan Dawes

unread,
Aug 23, 2017, 2:09:47 PM8/23/17
to Netty discussions
Never mind, I think I have realised that this is not the appropriate model for programming with Netty.

Rogan
Reply all
Reply to author
Forward
0 new messages