I have an HTTP producer that calls a remote HTTP Server. I need to read the response from the HTTP Server and convert it into json and do some further processing. I am experiencing some challenges dealing with big message bodies. I am not quite sure what the size threshold is. My code look
<from uri="restlet:/foo"/>
<setHeader headerName="Exchange.HTTP_URI">
<simple>{{ConfigurableURL}}}</simple>
</setHeader>
<to uri="http://dymmyhost"/>
<transform>
<simple>${bodyAs('java.lang.String')}</simple>
</transform>
<transform>
<groovy>org.json.simple.JSONValue.parse(request.body.trim())</groovy>
</transform>
When the size is small enough, this works without problem. When it is big, the body gets truncated in the last transformation. And if I remove org.json.simple.JSONValue.parse from this last transformation, I end up with a error message such as: org.apache.http.ConnectionClosedException: Premature end of Content-Length delimited message body (expected: 2263; received: 2233
My digging suggested that there is a buffering issue going on. So, I added the parameter disableStreamCache=true to the URL. It did not help.
I also replaced the JSON parsing line with a proper Camel unmarshaller:
<unmarshal ref="json"/>
Still it did not help. I get the exception: Premature end of Content-Length delimited message body.
Any clue?