Return-Path: X-Original-To: apmail-camel-issues-archive@minotaur.apache.org Delivered-To: apmail-camel-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D9D86979E for ; Wed, 11 Apr 2012 05:51:15 +0000 (UTC) Received: (qmail 75416 invoked by uid 500); 11 Apr 2012 05:51:15 -0000 Delivered-To: apmail-camel-issues-archive@camel.apache.org Received: (qmail 75371 invoked by uid 500); 11 Apr 2012 05:51:15 -0000 Mailing-List: contact issues-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list issues@camel.apache.org Received: (qmail 75343 invoked by uid 99); 11 Apr 2012 05:51:14 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 Apr 2012 05:51:14 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 Apr 2012 05:51:12 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 8761734A5D1 for ; Wed, 11 Apr 2012 05:50:52 +0000 (UTC) Date: Wed, 11 Apr 2012 05:50:52 +0000 (UTC) From: "Claus Ibsen (Resolved) (JIRA)" To: issues@camel.apache.org Message-ID: <233527547.11209.1334123452645.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <1053178219.432.1333373244360.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Resolved] (CAMEL-5136) File producer should support a flush attribute MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/CAMEL-5136?page=3Dcom.atlassia= n.jira.plugin.system.issuetabpanels:all-tabpanel ] Claus Ibsen resolved CAMEL-5136. -------------------------------- Resolution: Fixed Fix Version/s: (was: 2.8.5) =20 > File producer should support a flush attribute > ---------------------------------------------- > > Key: CAMEL-5136 > URL: https://issues.apache.org/jira/browse/CAMEL-5136 > Project: Camel > Issue Type: Improvement > Components: camel-core > Affects Versions: 2.8.4, 2.9.1 > Reporter: Jean-Baptiste Onofr=C3=A9 > Assignee: Claus Ibsen > Fix For: 2.9.2, 2.10.0 > > > Currently, the file operation doesn't flush the file change while writing= to the filesystem: > private void writeFileByFile(File source, File target) throws IOExcep= tion { > FileChannel in =3D new FileInputStream(source).getChannel(); > FileChannel out =3D null; > try { > out =3D prepareOutputFileChannel(target, out); > LOG.trace("Using FileChannel to transfer from: {} to: {}", in= , out); > long size =3D in.size(); > long position =3D 0; > while (position < size) { > position +=3D in.transferTo(position, endpoint.getBufferS= ize(), out); > } > } finally { > IOHelper.close(in, source.getName(), LOG); > IOHelper.close(out, target.getName(), LOG); > } > } > private void writeFileByStream(InputStream in, File target) throws IO= Exception { > FileChannel out =3D null; > try { > out =3D prepareOutputFileChannel(target, out); > LOG.trace("Using InputStream to transfer from: {} to: {}", in= , out); > int size =3D endpoint.getBufferSize(); > byte[] buffer =3D new byte[size]; > ByteBuffer byteBuffer =3D ByteBuffer.wrap(buffer); > int bytesRead; > while ((bytesRead =3D in.read(buffer)) !=3D -1) { > if (bytesRead < size) { > byteBuffer.limit(bytesRead); > } > out.write(byteBuffer); > byteBuffer.clear(); > } > } finally { > IOHelper.close(in, target.getName(), LOG); > IOHelper.close(out, target.getName(), LOG); > } > } > It means that the file can be visible on the filesystem quite a long time= after starting to send the exchanges to the file endpoint. > It could be interesting to add a flush attribute doing: > FileOutputStream os =3D ... > FileDescriptor fd =3D os.getFD(); > ... > os.write(data); > os.flush(); > fd.sync(); -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrato= rs: https://issues.apache.org/jira/secure/ContactAdministrators!default.jsp= a For more information on JIRA, see: http://www.atlassian.com/software/jira