title: Elasticsearch performRequestAsync how to return response to upper caller
body: <p>The Following is what I copy from Elasticsearch Official website</p>
  
  <p>"The Response object, either returned by the synchronous performRequest methods or received as an argument in ResponseListener#onSuccess(Response), wraps the response object returned by the http client"</p>
  
  <p><a href="https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/_reading_responses.html" rel="nofollow noreferrer">https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/_reading_responses.html</a></p>
  
  <p>The following is Async Function in ElasticSearchService Class
      public void getAsyncRequest(String endpoint, Map params, HttpEntity entity) {</p>
  
  <pre><code>    restClient.performRequestAsync("GET", endpoint, params, entity, new ResponseListener() {
          @Override
          public void onSuccess(Response response) {
              try {
                  LOGGER.info(EntityUtils.toString(response.getEntity()));
              } catch (IOException e) {
                  LOGGER.error(e.getMessage());
              }
          }
          @Override
          public void onFailure(Exception e) {
              LOGGER.error(e.getMessage());
          }
      });
  }
  </code></pre>
  
  <p>The following is another Class.</p>
  
  <pre><code>public static void main(String[] args) {
      ElasticSearchService.getAsyncRequest(endpoint, params, entity);
  }
  </code></pre>
  
  <p>So my question is, when calling getAsyncRequestWithBody, when it is onSuccess, then it will get response Object, but how do I return it back to the caller which is static "main" function.</p>
  
  <p>I didn't figure out what it means by "wraps the response object returned by the http client"</p>
  
  <p>Thank you for help.
  leochung</p>