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.

Reply via email to