cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bruno Melloni <>
Subject RE: Spring/CXF <jaxws:client> is it thread-safe?
Date Tue, 02 Feb 2010 19:19:58 GMT
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. Could not send Message.
	at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(
	at $Proxy61.recordWorkUnitResults(Unknown Source)
	at net.cndc.massbatch.client.ProcessBatchThread.recordWorkUnitResults(
Caused by: Read timed out

-----Original Message-----
From: Daniel Kulp [] 
Sent: Thursday, January 21, 2010 1:56 PM
Cc: Bruno Melloni
Subject: Re: Spring/CXF <jaxws:client> is it thread-safe?

Yea.   That all looks correct.


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 []
> Sent: Wednesday, January 20, 2010 2:58 PM
> To:
> Cc: Bruno Melloni
> Subject: Re: Spring/CXF <jaxws:client> is it thread-safe?
> See the faq:
> 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

View raw message