Uploaded image for project: 'JBoss Enterprise Application Platform'
  1. JBoss Enterprise Application Platform
  2. JBEAP-18687

Add How to set JAXRS Client timeouts

    XMLWordPrintable

Description

    2.2. JAX-RS Client

    With EAP 7.2+ , the JAXRS 2.1 included the ability to set the timeouts [2]. With this you do not have to use the ResteasyClientBuilder. ResteasyClientBuilder extends the javax.ws.rs.client.ClientBuilder , so if you do need to invoke some non spec method, you can still use ResteasyClientBuilder and call connectTimeout / readTimeout on it.

    These old methods on ResteasyClientBuilder were deprecated in favor of the spec methods:

    establishConnectionTimeout => connectTimeout
    socketTimeout => readTimeout

    import javax.ws.rs.client.ClientBuilder;
    import javax.ws.rs.client.Client;
    
     Client client = ClientBuilder.newBuilder()
                    .connectTimeout(100, TimeUnit.SECONDS)
                    .readTimeout(2, TimeUnit.SECONDS)
                    .build();
    

    We should clarify the standard way: 'Using the Standard Way to Create a Client' , is the JavaEE /JAXRS spec defined way, which is portable. Using the RESTEasy way is not portable since it depends on RESTEasy.

    [1] https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.3.beta/html/developing_web_services_applications/developing_jax_rs_web_services
    [2] https://javaee.github.io/javaee-spec/javadocs/javax/ws/rs/client/ClientBuilder.html

    Attachments

      Issue Links

        Activity

          People

            dfitzmau@redhat.com Darragh Fitzmaurice
            rhn-support-bmaxwell Brad Maxwell
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: