users@grizzly.java.net

How do I match responses to requests?

From: Jon Brisbin <jon_at_jbrisbin.com>
Date: Thu, 23 Jun 2011 08:13:56 -0500 (CDT)

I'm trying to write a TCP client in Grizzly and I can read and write just fine but I can't match the two. In other words, I'm not sure how, when I make a request, I can figure out what future I need to call to send the response back to the requestor. I'm assuming this client will be used for lots of concurrent requests with callbacks, so some responses might come in out-of-order from how they went out.

How do I "save" a future in some context somewhere so I can, when processing a response, figure out what request this was a response for? The examples and docs don't give me much in this department. I need some kind of "correlation id" or something...

Thanks!

Jon Brisbin
http//jbrisbin.com