definir tempo limite para o cliente jax rs
Quero definir um tempo limite de conexão para um cliente jax rs.
ClientConfig configuration = new ClientConfig();
configuration.property(ClientProperties.CONNECT_TIMEOUT, 1000);
configuration.property(ClientProperties.READ_TIMEOUT, 1000);
Client client = ClientBuilder.newClient(configuration);
Quando crio o cliente diretamente com um ClientConfig, recebo a seguinte mensagem:
Não foi possível encontrar um MessageBodyReader do tipo de conteúdo application / xml e tipo de classe.
Isso é o que eu tentei. Mas não funcionará, se eu tentar me conectar a um host errado, leva 20 segundos para obter uma ProcessingException. Também tentei definir a propriedade no webTarget, também não ajuda.
WebTarget target = client.target(protocol + "://" + host + ":" + port);
target = target.path(APPLICATION_PATH + REST_PATH);
target.property(ClientProperties.CONNECT_TIMEOUT, 1);
target.property(ClientProperties.READ_TIMEOUT, 1);