I seem to be having multi-threading problems with a shared CXF client port,
and I'm hoping that someone here can point me to the right direction as to
how to debug this. My setup is this:
1. I create a port instance and cache it. I have the following
configuration for the port to make it thread safe (according to Apache FAQ
and some forum posts):
((BindingProvider)
port).getRequestContext().put("thread.local.request.context", Boolean.TRUE);
((BindingProvider)
port).getRequestContext().put(HTTPClientPolicy.class.getName(), new
HTTPClientPolicy());
2. I spawn off multiple threads with each one using the same port instance.
3. For each thread, the port is configured with the following:
a.) properties are added to the request context (such as client
properties, url, timeout)
b.) TLSClientParameters are set in the port's HTTPConduit (with the
client parameters having the same values for all threads so having them
shared should be OK)
c.) Interceptors (WSS4JOutInterceptor) are added to the ClientProxy
4. Have each thread concurrently invoke the port
So after #4, it seems like all the threads function properly, but there's
always one where the port never receives a response and eventually times
out. I've verified that the messages are actually being sent properly and
that the responding server receives them all just fine. But that one thread
with that one port never seems to receive it. As the FAQ states that the
response context is always thread local, I'm not sure where to look for in
my code that is causing this problem. And I do believe this is a thread
safety issue as when I changed Step #1 to not cache the port, I don't get
this problem anymore. Any help will be appreciated...
Thanks!
--
View this message in context:
http://cxf.547215.n5.nabble.com/CXF-port-thread-safety-question-tp5721412.html
Sent from the cxf-user mailing list archive at Nabble.com.