samblake
samblake

Reputation: 1578

Set Timeout on CXF Proxy Client

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.

Upvotes: 6

Views: 6289

Answers (2)

samblake
samblake

Reputation: 1578

    HTTPClientPolicy clientConfig = WebClient.getConfig(service).getHttpConduit().getClient();
    clientConfig.setReceiveTimeout(10000);

Upvotes: 1

Jason Winnebeck
Jason Winnebeck

Reputation: 1274

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);

Upvotes: 6

Related Questions