I implemented these changes and for the most part they works. But occasionally a call fail on the client side, even though it seems to complete successfully on the server side. I am not sure if the failure is due to the client multi-threading or not. If it is not, it is very strange because the server-side process is very simple and quick, just a small update to the database. Even so, I plan on increasing the client receive timeout but it should not really be necessary.
Any help interpreting the errors would be quite helpful. This is the exception I see: 2010-02-02 12:33:39,164 ERROR [Thread-2] MbErrorMgr - [LCEIT1664,2]Error recording work assignment results. javax.xml.ws.soap.SOAPFaultException: Could not send Message. at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:141) at $Proxy61.recordWorkUnitResults(Unknown Source) at net.cndc.massbatch.client.ProcessBatchThread.recordWorkUnitResults(ProcessBatchThread.java:96) at net.cndc.massbatch.client.ProcessBatchThread.run(ProcessBatchThread.java:51) Caused by: java.net.SocketTimeoutException: Read timed out -----Original Message----- From: Daniel Kulp [mailto:dk...@apache.org] Sent: Thursday, January 21, 2010 1:56 PM To: users@cxf.apache.org Cc: Bruno Melloni Subject: Re: Spring/CXF <jaxws:client> is it thread-safe? Yea. That all looks correct. Dan On Wed January 20 2010 4:42:21 pm Bruno Melloni wrote: > Thank you Daniel, > > I was afraid there would be issues. Unfortunately the FAQ doesn't explain > how to do make the client calls threadsafe when using Spring. > > I took a stab at combining your reply with the FAQ instructions and how I > currently make CXF service calls with Spring. Could you (or anybody) > please look at it and correct me if I got it wrong? > > 1) In the client, get a reference to the proxy: > > ApplicationContext context = new ClassPathXmlApplicationContext( > new String[] {"mySpringContext-client.xml"}); > MyClientIF client = (MyClientIF)context.getBean("myServiceClientBeanID"); > > 2) Set the service client bean's requestContext to thread.local (presumably > the bean implements the BindingProvider interface automatically): > > ((BindingProvider)client).getRequestContext().put("thread.local.request.con > text", "true"); > > 3) Pass 'client' to the threads. > > 4) The threads call the service methods (presumably CXF calls > .requestContext() automatically as part of the service call): > > client.MyMethod(); > > > Thanks, > > bruno > > -----Original Message----- > From: Daniel Kulp [mailto:dk...@apache.org] > Sent: Wednesday, January 20, 2010 2:58 PM > To: users@cxf.apache.org > Cc: Bruno Melloni > Subject: Re: Spring/CXF <jaxws:client> is it thread-safe? > > > See the faq: > http://cxf.apache.org/faq.html > > Basically, if you use the request context, you could have issues if you > don't set the request context to be thread local. > > Dan > > On Wed January 20 2010 12:49:22 pm Bruno Melloni wrote: > > The approach of relying on Spring to get the CXF client object from the > > context is so convenient that I rarely think much about it. > > > > But I find myself needing to call the client from several concurrent > > threads and I am not sure but I believe that when I call > > context.getBean() I am retrieving a singleton instance of the client > > object. Is that going to be an issue when I call the same service method > > from multiple threads? > > > > The code behind the service call is already thread-safe. If I were > > calling it locally from multiple threads it would not be a problem. > -- Daniel Kulp dk...@apache.org http://www.dankulp.com/blog