Turns out the protocol I'm working with won't process the next request until sending the response of the current one, so I should be able to easily correlate requests and responses in the client with a simple Queue.
Thanks for the fast turn-around on help! :)
Thanks!
Jon Brisbin
http//jbrisbin.com
----- Original Message -----
> From: "Oleksiy Stashok" <oleksiy.stashok_at_oracle.com>
> To: users_at_grizzly.java.net
> Sent: Thursday, June 23, 2011 8:30:40 AM
> Subject: Re: How do I match responses to requests?
> 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
>