Return-Path: X-Original-To: apmail-camel-users-archive@www.apache.org Delivered-To: apmail-camel-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7A531110D9 for ; Fri, 25 Jul 2014 06:36:13 +0000 (UTC) Received: (qmail 61288 invoked by uid 500); 25 Jul 2014 06:36:13 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 61240 invoked by uid 500); 25 Jul 2014 06:36:13 -0000 Mailing-List: contact users-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@camel.apache.org Delivered-To: mailing list users@camel.apache.org Received: (qmail 61226 invoked by uid 99); 25 Jul 2014 06:36:12 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 25 Jul 2014 06:36:12 +0000 X-ASF-Spam-Status: No, hits=2.0 required=5.0 tests=SPF_NEUTRAL,URI_HEX X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [216.139.236.26] (HELO sam.nabble.com) (216.139.236.26) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 25 Jul 2014 06:36:11 +0000 Received: from [192.168.236.26] (helo=sam.nabble.com) by sam.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1XAZ6Y-0002tq-OP for users@camel.apache.org; Thu, 24 Jul 2014 23:35:46 -0700 Date: Thu, 24 Jul 2014 23:35:46 -0700 (PDT) From: rsteppac2 To: users@camel.apache.org Message-ID: <1406270146750-5754424.post@n5.nabble.com> Subject: Stream-only reverse proxy with minimal memory footprint MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org I am trying to implement a memory efficient http reverse proxy that is working on streams only to handle large HTTP requests and responses. This should be as easy as described here: http://camel.apache.org/how-to-use-camel-as-a-http-proxy-between-a-client-and-server.html The Jetty consumer places the socket input stream with the http POST body into the exchange and I can hook it up with a producer to forward the request. No problem here. The problem is the response. All http producers that I am aware of (Jetty, http4, netty-http) read the response stream into a byte-array,wrap it in an InputStream and place that in the exchange body. Thus a large http response blows my proxy out of the water. None of the producers seem to offer an option to make them put the original socket input stream into the exchange, just as the Jetty consumer does. http4: Everything happens in org.apache.camel.component.http4.HttpProducer::process() -> populateResponse(..) -> extractResponseBody(..) -> doExtractResponseBodyAsStream(); here the original stream is copied into an instance of CachedOutputStream, backed by a byte-array. Jetty: org.eclipse.jetty.client.AsyncHttpConnection::handle() -> org.eclipse.jetty.http.HttpParser::parseNext() will fill a byte-array in org.eclipse.jetty.client.ContentExchange which is a CachedExchange which is a HttpExchange. netty-http: Builds a pipeline that assembles the HttpResponse content as a composite ChannelBuffer. The wrapped channel buffers make up the complete response stream. Is there a way to configure any of the clients to place the socket input stream into the exchange body? This thread describes the same problem and proposes a patch, which I think has not made it into the Camel code base as of yet: http://camel.465427.n5.nabble.com/Chunking-issue-with-http-producer-td5735075.html The question is how to close the socket stream of the client. If I should have to replicate the suggested patch, would a Synchronization call-back registered with the exchange via Exchange::addOnCompletion(Synchronization) be the correct place to do it? I have tried with a FileInputStream and that seems to work. I.e. the call-back is triggered after the stream contents have been written out to the socket. Thanks! Ralf -- View this message in context: http://camel.465427.n5.nabble.com/Stream-only-reverse-proxy-with-minimal-memory-footprint-tp5754424.html Sent from the Camel - Users mailing list archive at Nabble.com.