title: Camel asynchronous call get the response
body: <p>I am making an asynchronous call to a webservice using apache camel API using below code:</p>
  
  <pre><code>    Exchange exchange = new DefaultExchange(context);
      Message msg = exchange.getIn();
      msg.setBody(requestStr);
      msg.setHeader("content-type", "application/json");
  
      template.asyncCallback("direct:invokeAPI", exchange, new Synchronization() {
          @Override
          public void onComplete(Exchange exchange) {
              System.out.println("Success");
              System.out.println(exchange);
              System.out.println(exchange.getIn());
              System.out.println(exchange.getIn().getHeaders());
              System.out.println(exchange.getIn().getBody());
              System.out.println("================================");
              System.out.println(exchange.getOut());
              System.out.println(exchange.getOut().getHeaders());
              System.out.println(exchange.getOut().getBody());
              System.out.println("================================");
              Exception ex = exchange.getException();
              System.out.println(ex.getMessage());
          }
  
          @Override
          public void onFailure(Exchange exchange) {
              System.out.println("Failure");
          }
      });
  </code></pre>
  
  <p>Now my webservice is failing with an exception and it is returning a json response:</p>
  
  <pre><code>Response-Code: 500
  Content-Type: application/json
  Headers: {Content-Type=[application/json], Date=[Fri, 03 Aug 2018 13:18:19 GMT]}
  Payload: {"errorMessage":"Unable to process","errorCode":"500"}
  </code></pre>
  
  <p>Now how can I capture this information in my <code>template.asyncCallback</code> method.
  In my above code it is going to <code>onComplete</code> callback method and printing below messages : </p>
  
  <pre><code>Success
  Exchange[ID-xxxx-0-2]
  Message[ID-xxxx-0-1]
  {breadcrumbId=ID-xxxx-0-1, content-type=application/json}
  {
  "source":"PDF"
  }
  ================================
  Message[]
  {}
  null
  ================================
  </code></pre>
  
  <p>I am trying to get the status 500 code and the response payload that has the error information, but I am not able to print anything. Can you please help me what is the correct way to get the error information.</p>