cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sergey Beryozkin <sbery...@progress.com>
Subject Re: is webclient thread safe ?
Date Tue, 09 Feb 2010 11:16:20 GMT
Hi

Unfortuntately not, not yet.
However, you can do the following on every request, after it has been injected :

public class SomeService {
private WebClient injectedWc = ...

@POST
public void doIt() {

    // copy-constructor-like creation
    WebClient currentWc = WebClient.fromClient(injectedWc, true);
    // or just WebClient.fromClient(injectedWc);

    currentWc.post(...)
}

}


The currentWc will get all the configuration the injectWc has, including the headers which
might've been set on it on the init time 
(the 2nd 'true' parameter). WebClient.fromClient() can be used to 'convert' proxies into WebClients
too. I've been thinking about 
the tread-safety of a single client earlier on and at a time I chose to have methods like
WebClient.getResponse() or 
WebClient.back() working well. I reckon WebClient.fromClient() can be quite a cheap alternative
(albeit with some extra effort from 
a user) to making sure a proxy/client is thread-safe internally, however, I'll be looking
into this issue with more attention once I 
get into working on enhancing the client api (on the map)...

Hope it helps, Sergey

Hi

How thread safe is WebClient.  Can it be injected (spring wired) into a
bean, and reused on a per request basis to call a downstream web service
?



Thanks for any guidance

Paul


This e-mail (and any attachments) is confidential and may contain personal views which are
not the views of the BBC unless 
specifically stated. If you have received it in error, please delete it from your system.
Do not use, copy or disclose the 
information in any way nor act in reliance on it and notify the sender immediately.

Please note that the BBC monitors e-mails sent or received. Further communication will signify
your consent to this

This e-mail has been sent by one of the following wholly-owned subsidiaries of the BBC:

BBC Worldwide Limited, Registration Number: 1420028 England, Registered Address: BBC Media
Centre, 201 Wood Lane, London, W12 7TQ
BBC World News Limited, Registration Number: 04514407 England, Registered Address: BBC Media
Centre, 201 Wood Lane, London, W12 7TQ
BBC World Distribution Limited, Registration Number: 04514408, Registered Address: BBC Media
Centre, 201 Wood Lane, London, W12 7TQ





Mime
View raw message