Can't use Apache Camel requestBody properly

268 views Asked by At

I am using Apcahe Camel and Spring boot, my objective is to use Camel to make a request to a REST API and get the response.

And i have this Request Mapping:

@RequestMapping("/annotation")
    String getAnnotation(@RequestBody JSONObject payload) {

        Object info = producerTemplate.requestBody("direct:annotation", payload, Object.class);
        return info.toString();
    } 

And this route;

from("direct:annotation").
        convertBodyTo(String.class).
        log("Receiving a annotation request").
                to("http4://"+ address +"/annotation");

When I Make a Request to /annotation i receive as response:

org.apache.camel.converter.stream.CachedOutputStream$WrappedInputStream@7d5a6dba

And I Would like to receive the body of the message which in this case is a JSON.

1

There are 1 answers

1
Dan Serb On BEST ANSWER

Try to get rid of Object type, try using a String instead. You are using info.toString() on a Object and that's the reason you get that printed.