0

I am looking to set timeout for every request object in RestEasy. Jersey gives the same functionality through request properties. Please refer this answer - https://stackoverflow.com/a/36056418

   // overriden timeout value for this request
   request.property(ClientProperties.CONNECT_TIMEOUT, 500);
   request.property(ClientProperties.READ_TIMEOUT, 500);

I couldn't find similar feature for RestEasy. The feature to configure it per Client is available, but because of the framework we use the Client is instantiated at startup & reused for all requests.

Thanks

CBT
  • 3
  • 3

1 Answers1

0

As explained on jboss v7.3 by redhat website :

  • The connectTimeout method determines how long the client must wait when making a new server connection.
  • The readTimeout method determines how long the client must wait for a response from the server.

So this should be good for your case:

Client client = ClientBuilder.newBuilder()
           .connectTimeout(100, TimeUnit.SECONDS)
           .readTimeout(2, TimeUnit.SECONDS)
           .build();
g.momo
  • 536
  • 2
  • 7