users@grizzly.java.net

Re: How do I match responses to requests?

From: Oleksiy Stashok <oleksiy.stashok_at_oracle.com>
Date: Thu, 23 Jun 2011 15:30:40 +0200

Hi Jon,

you're implementing some custom protocol?
If your protocol allows next request to be sent before response for the
prev. request has been received - then you'd probably need to correlate
requests and responses on the protocol level.
Let's say you can define ID field in your protocol and correlate
requests and responses using that ID.

You can share some code, so we can understand what exactly you're doing
and try to help.

Thanks.

WBR,
Alexey.

On 06/23/2011 03:13 PM, Jon Brisbin wrote:
> 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
>
>