On Mon, Apr 30, 2012 at 3:27 PM, rdifrango <ron.difra...@gmail.com> wrote:
> So, I converted this over to Java and it is exhibiting the same behavior.
> What did I do wrong:
>
> public class JavaSplitPerfProcessor {
>        static class LineSplitter implements Processor {
>                static final String format = "INSERT INTO EVT_PERF ( 
> EVT_PERF_ID,
> CRLTN_ID, USER_ID, APPN_SYS_CD, HOST_NM, WEBLOGIC_INSTNC_NM,
> WEB_ANLYTCS_CRLTN_ID, LOGGER_CLASS_NM, EXEC_TIME ) values (
> EVT_PERF_ID_SEQ.NEXTVAL, ''{0}'', ''{1}'', ''{2}'', ''{3}'', ''{4}'',
> ''{5}'', ''{6}'', {7} )";
>
>                @Override
>                public void process(Exchange exchange) throws Exception {
>                        // Get the incoming line from the message exchange
>                        String line = exchange.getIn().getBody(String.class);
>                        // Remove the first part of the log message
>                        String[] lineSplit = line.split("\\[\\]\\: ");
>                        // Break it down into the individual components
>                        String[] split = lineSplit[1].split(" ");
>                        // Build the insert statement
>                        String x = MessageFormat
>                                        .format(format, split[0], split[1], 
> split[2], split[3],
>                                                        split[4], split[5], 
> split[7], split[10]);
>                        // Replace the incoming message with the insert 
> statement
>                        exchange.getIn().setBody(x);
>                }
>        }
>
>        public static void main(String[] args) throws Exception {
>                // Build the connection pool
>                BasicDataSource ds = new BasicDataSource();
>                ds.setDriverClassName("oracle.jdbc.OracleDriver");
>                ds.setUrl("jdbc:oracle:thin:@localhost:1521:xe");
>                ds.setUsername("****");
>                ds.setPassword("****");
>                // Register it with Camel
>                SimpleRegistry reg = new SimpleRegistry();
>                reg.put("dataSource", ds);
>
>                final LineSplitter lineSplitter = new LineSplitter();
>
>                CamelContext context = new DefaultCamelContext(reg);
>                context.addRoutes(new RouteBuilder() {
>                        public void configure() {
>                                
> from("file:perf?delete=true").split(body().tokenize("\n"))
>                                                
> .streaming().process(lineSplitter)
>                                                
> .to("jdbc:dataSource?resetAutoCommit=false").end();
>                        }
>                });
>
>                context.start();
>                Thread.sleep(60000);
>                context.stop();
>        }
> }
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/File-Processor-Not-deleting-the-files-tp5670301p5675961.html
> Sent from the Camel - Users mailing list archive at Nabble.com.

Windows is always a bit tricky with its file system.

I suspect this line
    String line = exchange.getIn().getBody(String.class);

Despite we close the buffers un the hood, the JDK may not close
wrapped buffers, which may lead
to the FileInputStream not being closed, and Windows not able to
delete the source file when the processing is done.

I got a XP box for testing. So let see what that old fella says.



-- 
Claus Ibsen
-----------------
CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
FuseSource
Email: cib...@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Reply via email to