You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by ramrubio <ra...@yahoo.com> on 2013/07/22 18:37:25 UTC

StreamCaching with slip not working

SampleProxySvc.zip
<http://camel.465427.n5.nabble.com/file/n5736044/SampleProxySvc.zip>  

Camel version = 2.11.0
commons.httpclient version = 3.0.1

Attempting to implement a proxy service to route requests dynamically using
DynamicRouter pattern suggested by
http://camel.apache.org/dynamic-router.html.

I'm unsuccessful though in getting streamcaching to work.  I've enabled
streamcaching on the CamelContext but when the proxysvc forwards the POST
request to my endpoint the body is always empty.

Attached is my code with two projects. 

1.  sample.proxysvc - Contains camel proxy 
2.  sample.restsvc - Simple rest servicSampleProxySvc.zipe 


You will notice that proxysvc enables streamcaching on camel context in
camel-config.xml.  When a POST request is made to sample REST service body
is always empty. 

The only way i'm able to get it to work is by attaching a processor and
reading body into a string and setting setting in http request (Currently
this code is commented). 

I'm sure i'm doing something wrong to enable stream caching.  Hopefully it
is something easy that may be pointed out. 

Thank You. 

/Ramon



--
View this message in context: http://camel.465427.n5.nabble.com/StreamCaching-with-slip-not-working-tp5736044.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: StreamCaching with slip not working

Posted by Claus Ibsen <cl...@gmail.com>.
This is a bug in Camel and has been fixed recently. So will be fixed
in upcoming releases.

On Mon, Jul 22, 2013 at 8:44 PM, ramrubio <ra...@yahoo.com> wrote:
> Stepping through code noticed that InputStreamRequestEntity is used during
> post request.
>
> A call to InputStreamRequestEntity.getContentLength leads to a call to
> bufferContent because contentLength is set to CONTENT_LENGTH_AUTO.  The type
> of inputStream that is set in InputStreamRequestEntity is of type
> InputStreamCache.
>
> Because position is set to the end of the inputstream (see below) the call
> to bufferContent results in buffer set to empty and the size is updated to
> 0.  This causes POST request to always have an empty body.
>
> this    InputStreamRequestEntity  (id=169)
>         buffer  null
>         content InputStreamCache  (id=146)
>                 buf      (id=154)
>                 count   10
>                 mark    0
>                 pos     10
>         contentLength   -2
>         contentType     "application/json" (id=172)
>
> Is this expected?
>
> /Ramon
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/StreamCaching-with-slip-not-working-tp5736044p5736047.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: StreamCaching with slip not working

Posted by ramrubio <ra...@yahoo.com>.
Stepping through code noticed that InputStreamRequestEntity is used during
post request.

A call to InputStreamRequestEntity.getContentLength leads to a call to
bufferContent because contentLength is set to CONTENT_LENGTH_AUTO.  The type
of inputStream that is set in InputStreamRequestEntity is of type
InputStreamCache.  

Because position is set to the end of the inputstream (see below) the call
to bufferContent results in buffer set to empty and the size is updated to
0.  This causes POST request to always have an empty body.

this	InputStreamRequestEntity  (id=169)	
	buffer	null	
	content	InputStreamCache  (id=146)	
		buf	 (id=154)	
		count	10	
		mark	0	
		pos	10	
	contentLength	-2	
	contentType	"application/json" (id=172)

Is this expected?

/Ramon





--
View this message in context: http://camel.465427.n5.nabble.com/StreamCaching-with-slip-not-working-tp5736044p5736047.html
Sent from the Camel - Users mailing list archive at Nabble.com.