Hi All.
I'm using cxf client against a service which for some reason has a high
latency on all responses. Due to this, I'm trying to use async
responses to issue a bunch of requests at once, then process the
responses as they come in. This seems to work, in that the total
execution time is significantly shortened (i.e. the remote system is
really just wasting cycles, not actually doing time-consuming activity).
However, when I process the responses, they MUST be processed by the
original single thread that submitted the requests, due to other
systematic issues beyond the scope of this project.
(As an aside, as I understand, there's no way to wait for "any" Future
in the java api, but I could be missing something)
Anyway, I'm using a BlockingQueue and my AsyncHandler class takes the
response object and jams it into the BlockingQueue and the main thread
"takes" it from there.
So far this is working, but I have a very fragile way of terminating the
main thread's loop on taking responses out of the queue. I currently am
counting the number of requests sent, but it is very easy to forget to
increment the counter I'm using, and I figure there must be a better way
to do this, either by checking directly some internal counter of
pending responses, or some other better trick. Also, I think my actual
"service" instance (defined by <jaxws:client />) is a singleton and may
be shared by other threads, in which case I would only want wait for
requests submitted by the calling thread and not grab or wait for
requests submitted in other threads.
Any recommendations?
Thanks,
David Mansfield
Cobite, INC.