Set Timeout on CXF Proxy Client
Asked Answered
A

2

6

I have a JAX-RS client in CXF created via JAXRSClientFactoryBean.create. How can I set the connection/receive timeouts?

I assume I need to get hold of the conduit but can't work out how to. This project is not using Spring.

Acting answered 9/1, 2015 at 14:32 Comment(0)
A
1
    HTTPClientPolicy clientConfig = WebClient.getConfig(service).getHttpConduit().getClient();
    clientConfig.setReceiveTimeout(10000);
Acting answered 21/5, 2015 at 15:26 Comment(1)
Just realised this is the same as the previous answer. I thought it wasn't applicable because it wasn't for a bean but it turns out it works for both.Acting
O
6

Here's the code I use:

service = JAXRSClientFactory.create(url, serviceClass, providers);
HTTPConduit conduit = WebClient.getConfig(service).getHttpConduit();
HTTPClientPolicy policy = new HTTPClientPolicy();
policy.setReceiveTimeout(300000); //5 minutes
conduit.setClient(policy);
Overleap answered 29/1, 2015 at 12:45 Comment(2)
I think I'm confused, are you talking about JAX-WS or JAX-RS? Your question says "I have a JAX-WS client" but "created via JAXRSClientFactoryBean", which creates JAX-RS clients?Overleap
OK, then for a CXF JAX-RS proxy client, my solution is what I've used for JAX-RS.Overleap
A
1
    HTTPClientPolicy clientConfig = WebClient.getConfig(service).getHttpConduit().getClient();
    clientConfig.setReceiveTimeout(10000);
Acting answered 21/5, 2015 at 15:26 Comment(1)
Just realised this is the same as the previous answer. I thought it wasn't applicable because it wasn't for a bean but it turns out it works for both.Acting

© 2022 - 2024 — McMap. All rights reserved.