Hi You are doing a bit low level coding by creating producer/consumer etc. Often people just use routes.
Anyway the problem is when you do like this, you need to trigger the done of the exchange, which will cause the file to be moved. See the javadoc for PollingConsumer /** * Represents a <a * href="http://camel.apache.org/polling-consumer.html">Polling * Consumer</a> where the caller polls for messages when it is ready. * <p/> * When you are done with the returned {@link Exchange} you must ensure to invoke * {@link org.apache.camel.spi.UnitOfWork#done(Exchange)} to signal to Camel that the {@link Exchange} is done. * <p/> * This is needed to ensure any {@link org.apache.camel.spi.Synchronization} works is being executed. * For example if you consumed from a file endpoint, then the consumed file is only moved/delete when * you done the {@link Exchange}. * * @version */ You can do this something like consumerX.getUnitOfWork().done(consumerX); On Thu, Oct 6, 2011 at 4:13 PM, ebinsingh <ebenezer.si...@verizonwireless.com> wrote: > Hi, > > I am having trouble moving a file to a back up location after it's consumed > and it's contents sent to a queue. > > I am new to Camle world and exploring it. Below is the code am using. > > *Spring config:* > > <bean id="routeProperties" > class="com.verizon.learn.camel.utils.RoutingProperties"> > <constructor-arg > index="0"><value>file:C:\\camelProject\\data\\inbox?move=C:\\camelProject\\data\\inbox\\bkp</value></constructor-arg> > <constructor-arg > index="1"><value>file:C:\\camelProject\\data\\outbox\\bkp</value></constructor-arg> > <constructor-arg > index="2"><value>jms:queue:test_queue</value></constructor-arg> > </bean> > > > Code snippet: > > System.out.println("Starting Polloer: > "+consumerEndpoint); > PollingConsumer consumer = > consumerEndpoint.createPollingConsumer(); > Producer producer = targetEndpoint.createProducer(); > consumer.start(); > while(true){ > Exchange consumerX = consumer.receive(timeout); > while(consumerX != null){ > System.out.println("Received message: > " + consumerX.getIn().getBody()); > Exchange newExchange = > producer.createExchange(consumerX); > > newExchange.getIn().setBody(consumerX.getIn().getBody()); > > newExchange.getIn().setHeaders(consumerX.getIn().getHeaders()); > producer.process(newExchange); > > consumerX = consumer.receive(timeout); > } > Thread.sleep(1000); > } > }catch(Exception ex){ > ex.printStackTrace(); > } > > -- > View this message in context: > http://camel.465427.n5.nabble.com/Move-does-not-work-with-file-polling-tp4876472p4876472.html > Sent from the Camel - Users mailing list archive at Nabble.com. > -- Claus Ibsen ----------------- 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/