If that's the ONLY use of the request context, I would definitely flip to option #2. Using a thread local request context would consume a bit more memory since there is extra stuff to store per thread, a bit of extra setup, etc… However, if you need the thread local context for other contextual things, then option 1 is likely a bit better as you'd have already hit all that setup cost.
Dan On Aug 16, 2013, at 7:27 AM, Gaurav Chandna <[email protected]> wrote: > I am able to set webservice client's receive timeout at web-operation level > rather than webservice level in following 2 ways: > > > *Option1: HTTP POLICY* > sample code: > > CustomerService service = getService(); > long t = System.currentTimeMillis(); > System.out.println("Start time-->" + t); > try { > HTTPClientPolicy policy = new HTTPClientPolicy(); > policy.setReceiveTimeout(3000); > > ((BindingProvider)service).getRequestContext().put("*thread.local.request.context"*,"true"); > > > ((BindingProvider)service).getRequestContext().put(HTTPClientPolicy.class.getName(), > > policy); > > *Option 2: Interceptor Level- Message Object setting* > Sample Code: > > public class OutTimeoutInterceptor extends > AbstractPhaseInterceptor<Message> { > private int receiveTimeout; > public OutTimeoutInterceptor() { > *super(Phase.PREPARE_SEND); * } > @Override > public void handleMessage(Message message) throws Fault { > if("{ > http://customerservice.example.com/}CustomerServiceServiceSoapBinding".equals(message.getExchange().getBindingOperationInfo().getBinding().getName().toString())) > > { > *message.put(Message.RECEIVE_TIMEOUT, 2000); * } > } > > > > Question: Which is the better option from above to use from performance and > multi threaded perspective? Our application invloves huge multi threading > > > > -- > View this message in context: > http://cxf.547215.n5.nabble.com/Webservice-Client-Receive-Timeout-options-HttpClientPolicy-setReceiveTimeout-VS-Interceptor-Message-t-tp5732557.html > Sent from the cxf-user mailing list archive at Nabble.com. -- Daniel Kulp [email protected] - http://dankulp.com/blog Talend Community Coder - http://coders.talend.com
