You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Gnanaguru S <gn...@wipro.com> on 2012/04/27 10:43:17 UTC

File Overwrite using camel

Hi 

I am doing a simple route using camel

<from uri:"file?fileName=//input/test.txt"/>
<to uri:"file://output"/>

Now If I keep a file test.txt, It will transfer to output folders, But I
want this to happen every 10 seconds. Every time it writes, It should not
write a new file. But it should overwrite the existing file. 

Because the source will be updated by one system, And the target file should
be updated the same way.

How can I do that ?

Regards
Guru




--
View this message in context: http://camel.465427.n5.nabble.com/File-Overwrite-using-camel-tp5669708p5669708.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: File Overwrite using camel

Posted by Stefan Burkard <sb...@gmail.com>.
Hi

Not sure if I get your question, but to write files there is an option
"fileExist". This option defaults to "Override". Other options would
be "Append", "Fail" and "Ignore".

But since the default seems to be what you want, I don't really
understand the problem :-)

Stefan


On Fri, Apr 27, 2012 at 10:43, Gnanaguru S
<gn...@wipro.com> wrote:
>
> Hi
>
> I am doing a simple route using camel
>
> <from uri:"file?fileName=//input/test.txt"/>
> <to uri:"file://output"/>
>
> Now If I keep a file test.txt, It will transfer to output folders, But I
> want this to happen every 10 seconds. Every time it writes, It should not
> write a new file. But it should overwrite the existing file.
>
> Because the source will be updated by one system, And the target file should
> be updated the same way.
>
> How can I do that ?
>
> Regards
> Guru
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/File-Overwrite-using-camel-tp5669708p5669708.html
> Sent from the Camel - Users mailing list archive at Nabble.com.

Re: File Overwrite using camel

Posted by Gnanaguru S <gn...@wipro.com>.
Thanks Everybody.

Sorry Baba. I am miserably sorry. And Thanks for bearing me and answering my
questions in a apt way.

And cool this code worked great. As I expected.

route>
           <from
uri="file://input?fileName=test.txt&amp;delay=1000&amp;idempotent=false&amp;noop=true&amp;fileExist=Override"/> 
<to uri="activemq1:queue:test"/>
<to uri="log:SUCCESS"/>

</route>
<route>
           <from uri="activemq1:queue:test"/>
	   <to uri="file://output"/>
<to uri="log:SUCCESS"/>
        </route>

And Stefan, Let me try it out in producer. But this worked fine.

Regards
Guru

--
View this message in context: http://camel.465427.n5.nabble.com/File-Overwrite-using-camel-tp5669708p5670678.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: File Overwrite using camel

Posted by Stefan Burkard <sb...@gmail.com>.
by the way: fileExist=Override is a producer option. so you should not
use it on the consumer (from)

stefan


On Fri, Apr 27, 2012 at 12:30, Babak Vahdat <ba...@swissonline.ch> wrote:
> Hi
>
> IMHO for each single step of progress you're trying to make you're asking
> again and again before trying to investigate a bit by *yourself*!
>
> So I propose you to:
> - Look at the Camel source and it's own unit-tests to see if there's
> something out there coverning your use case
> - Search the User-Forum for similar questions
> - And there's also something called "Google"
>
> Back to you question:
>
> If with the keyword "queue" you do mean JMS queue, then yes it's possible:
>
> https://svn.apache.org/repos/asf/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/FileRouteToJmsToFileTest.java
>
> Babak
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/File-Overwrite-using-camel-tp5669708p5669929.html
> Sent from the Camel - Users mailing list archive at Nabble.com.

Re: File Overwrite using camel

Posted by Babak Vahdat <ba...@swissonline.ch>.
Hi

IMHO for each single step of progress you're trying to make you're asking
again and again before trying to investigate a bit by *yourself*!

So I propose you to:
- Look at the Camel source and it's own unit-tests to see if there's
something out there coverning your use case
- Search the User-Forum for similar questions
- And there's also something called "Google"

Back to you question:

If with the keyword "queue" you do mean JMS queue, then yes it's possible:

https://svn.apache.org/repos/asf/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/FileRouteToJmsToFileTest.java 

Babak

--
View this message in context: http://camel.465427.n5.nabble.com/File-Overwrite-using-camel-tp5669708p5669929.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: File Overwrite using camel

Posted by Gnanaguru S <gn...@wipro.com>.
And will all this file operation work between a queue ?


LIke this....

<from
uri="file://input?fileName=test.txt&amp;delay=1000&amp;idempotent=false&amp;noop=true&amp;fileExist=Override"/> 
<to queue>

<from queue>
<to uri="file://output"/>




Regards
Guru

--
View this message in context: http://camel.465427.n5.nabble.com/File-Overwrite-using-camel-tp5669708p5669871.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: File Overwrite using camel

Posted by Gnanaguru S <gn...@wipro.com>.
Thanks Stefan and Claus for the clue. 

Great. It worked for the following route/.

<from
uri="file://input?fileName=test.txt&amp;delay=1000&amp;idempotent=false&amp;noop=true&amp;fileExist=Override"/> 
<to uri="file://output"/>


Camel is Great always. I could have been writing 200 lines of code for this
else.

Regards
Guru

--
View this message in context: http://camel.465427.n5.nabble.com/File-Overwrite-using-camel-tp5669708p5669851.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: File Overwrite using camel

Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, Apr 27, 2012 at 10:43 AM, Gnanaguru S
<gn...@wipro.com> wrote:
>
> Hi
>
> I am doing a simple route using camel
>
> <from uri:"file?fileName=//input/test.txt"/>
> <to uri:"file://output"/>
>
> Now If I keep a file test.txt, It will transfer to output folders, But I
> want this to happen every 10 seconds. Every time it writes, It should not
> write a new file. But it should overwrite the existing file.
>
> Because the source will be updated by one system, And the target file should
> be updated the same way.
>
> How can I do that ?
>

1)
You want to only pickup a file named - test.txt?

2)
You want this to happen every 10 sec
Use the delay=10s option


3)
And what should happen when after the file has been processed? Should
it be kept in the source folder, or moved, or deleted?

Use idempotent=false and/or noop=false, or move=xxx etc




> Regards
> Guru
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/File-Overwrite-using-camel-tp5669708p5669708.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



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

Re: File Overwrite using camel

Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, Apr 27, 2012 at 10:43 AM, Gnanaguru S
<gn...@wipro.com> wrote:
>
> Hi
>
> I am doing a simple route using camel
>
> <from uri:"file?fileName=//input/test.txt"/>
> <to uri:"file://output"/>
>
> Now If I keep a file test.txt, It will transfer to output folders, But I
> want this to happen every 10 seconds. Every time it writes, It should not
> write a new file. But it should overwrite the existing file.
>
> Because the source will be updated by one system, And the target file should
> be updated the same way.
>
> How can I do that ?
>

Can you read the documentation first please.
http://camel.apache.org/file2

See the options for the file component, eg the producer has a
fileExist option that by default is Override. You can set it to Append
instead.


> Regards
> Guru
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/File-Overwrite-using-camel-tp5669708p5669708.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



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