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 CD9B18FE7 for ; Fri, 12 Aug 2011 15:10:40 +0000 (UTC) Received: (qmail 44974 invoked by uid 500); 12 Aug 2011 15:10:40 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 44908 invoked by uid 500); 12 Aug 2011 15:10:39 -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 44900 invoked by uid 99); 12 Aug 2011 15:10:39 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 12 Aug 2011 15:10:39 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FREEMAIL_FROM,MIME_QP_LONG_LINE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of magnus.palmer.work@gmail.com designates 209.85.214.45 as permitted sender) Received: from [209.85.214.45] (HELO mail-bw0-f45.google.com) (209.85.214.45) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 12 Aug 2011 15:10:30 +0000 Received: by bkbzv3 with SMTP id zv3so2147006bkb.32 for ; Fri, 12 Aug 2011 08:10:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=subject:references:from:content-type:x-mailer:in-reply-to :message-id:date:to:content-transfer-encoding:mime-version; bh=bcZz4T9P0bxGe5HtgUAsTPbMz63Cawg39q7Xrt0Yvws=; b=dUL+GJ8/EqDV1q0oLgYO6TWfASaPe+y94vTGJTW/6MNTYrRduqC1q6J+D3R+wI9PkV J6T7nwk6apX299yxe6YBMplPkkcJpuIvco+JfyMH3iJBkMWTtfQcje+CFCI2MAefs7w+ QZd3R1W0aGcq3fSPiQamomTfW5rBJN31GYv+o= Received: by 10.204.37.140 with SMTP id x12mr418541bkd.182.1313161809604; Fri, 12 Aug 2011 08:10:09 -0700 (PDT) Received: from [192.168.0.232] (95.209.179.48.bredband.tre.se [95.209.179.48]) by mx.google.com with ESMTPS id p12sm834385bkp.1.2011.08.12.08.10.08 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 12 Aug 2011 08:10:09 -0700 (PDT) Subject: Re: From http4 via md5checksum to FTP: file cache or streaming ? References: From: =?utf-8?Q?Magnus_Palm=C3=A9r?= Content-Type: text/plain; charset=utf-8 X-Mailer: iPhone Mail (8G4) In-Reply-To: Message-Id: Date: Fri, 12 Aug 2011 17:10:07 +0200 To: "users@camel.apache.org" Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (iPhone Mail 8G4) X-Virus-Checked: Checked by ClamAV on apache.org I would make your md5bean return a file.=20 Not sure if the current Jira issue of not cleaning (deleting) the file until= JVM stops will apply for you then or not. Don't have the link to it right now. --=20 Magnus Palm=C3=A9r +46 736 845680 12 aug 2011 kl. 16:51 skrev wing-tung Leung : > Hello, >=20 > one of our routes pulls binary data from from a HTTP service using > http4, and then uploads the binary to a remote FTP directory. It also > uses temporary files on the local filesystem behind the scenes , which > makes sense because the binary image data can grow up till 10MB. >=20 > Now I want to add one extra step: MD5 checksum verification just after > the download. Because of the size, I prefer not to load all the data > into a byte array to calculate a simple checksum, and use a > InputStream instead. At first sight this seems to work. In the > debugger, I can see this input stream is a wrapper around the locally > cached file, and at the end of the function I return the original > input stream. >=20 > This is how the route currently looks like: > > > >=20 > The processing bean method's signature: > InputStream process(InputStream buffer, > @Header("mgws_file_md5sum") String expectedChecksum) >=20 >=20 > But now the route seems to hang. I assume returning the "used" input > stream is wrong, since the FTP component can't do anything useful with > this anymore. I basically see options to fix this: > 1 - use fancy stream interception with a custom HttpBinder for http4, > integrating MD5 checksum calculation on the fly > 2 - redirect to temporary file explicitly, start a new route for the > checksum, reuse same file for FTP upload and cleanup manually >=20 >=20 >=20 > Any other recommendations? I think this is a quite common use case, so > I guess more experienced Camel user may want to give some useful > advice to a novice like me .. >=20 > Some pages I have been looking at: > http://camel.apache.org/http4.html > http://camel.apache.org/file2.html > http://camel.apache.org/stream-caching.html >=20 > (using Camel 2.6) >=20 > Thanks! >=20 > Tung