0

I am trying to retrieve an object out of the process method in Camel response.

However once I got an empty response in the following code:

from("timer://simpleTimer?repeatCount=1").routeId("myroute")
 .setHeader("client_id", constant("abc"))
 .setHeader("client_secret",constant("def"))
 .setHeader(Exchange.HTTP_METHOD, constant("POST"))
 .setHeader(Exchange.CONTENT_TYPE, constant("application/json"))
 .setHeader(Exchange.HTTP_URI, constant(url))
 .marshal().json(JsonLibrary.Gson)
 .log("trying to send message")
 .to(url)
 .convertBodyTo(String.class)
 .process(new Processor(){
     @Override
     public void process(Exchange exchange) throws Exception {
          final Message message = exchange.getIn();
          int responseCode = message.getHeader(Exchange.HTTP_RESPONSE_CODE, Integer.class);
          final String responseBody = message.getBody(String.class);
          System.out.println("in final block of process:" +
          responseCode + ",Body class name=" + responseBody.getClass()+
          "body="+responseBody);
     }
 );

Here body is not being printed.This is strange as the body is being printed

I need a JSON representation back and also want to store it in a object so that we can return it while returning thi object from this method.

Is there something missing?What should be added to meet the requirement?

Rachit
  • 403
  • 10
  • 32
  • Share NPE with stacktrace – c0ld Mar 05 '20 at 12:43
  • 1
    Sorry, I think you have to rewrite your question. I absolutely don't understand what your question is. And sentences like "Here body is not being printed.This is strange as the body is being printed" are very confusing. – burki Mar 06 '20 at 16:07

0 Answers0