users@grizzly.java.net

Associating executor with client request/connection

From: Daniel Feist <dfeist_at_gmail.com>
Date: Wed, 8 Apr 2015 02:13:05 +0100

Hi,

Looking for ideas for how I might do this:

- I have a single shared Grizzzly/AHC 'client' instance.
- This client can be used by multiple "flows" as it doesn't make sense to
have multiple instances of AHC each with it's own set of selectors.
- Each "flow" has it's own context, worker thread pool and error handling
etc.

Because further processing may occur in a given "flow" after a callback
caused by a http response being recieved I want to be able to use the
"flow's" thread pool, and not i) SameThreadIOStrategy ii) A
WorkerThreadIOStrategy with a shared worker thread pool.

I'm happy to create my own IOStrategy, thats a must, and I assume it's easy
enough to
implement org.glassfish.grizzly.strategies.AbstractIOStrategy#getThreadPoolFor()
and pull the Flow/Executor instance from the connection context via an
"Attribute".

But where I'm stuck and could do with some ideas, is the best way to
associate a "flow" or "Executor" instance with a given request/connection
in the first place, so that I have it available in the connection context
when the response comes back in. Ideally I'd be able to do this without
hacking AHC GrizzlyHttpProvider, but if that's not possible then I might
need to.

thanks!

Dan