Hey,

If you configure the file producer endpoint to use a fixed filename and
append any messages to it instead of replacing it, you'll get 1 file that
lists all received messages.

There are 2 ways to set the filename;

1:
from("http://localhost/testservice/resources/1";)
.setHeader(FileComponent.HEADER_FILE_NAME, constant("output.txt"))
.to("file:/target/")

2:
from("http://localhost/testservice/resources/1";)
.to("file:/target/output.txt?autoCreate=false")

Autocreate must be set to false here because otherwise the file component
will create a directory called 'output.txt', and write those 100 files
there.


To make sure the messages are not overwriting each-other you set append to
true:

from("http://localhost/testservice/resources/1";)
.to("file:/target/output.txt?autoCreate=false&append=true")

Even though the default value of append is 'true', its always a good idea
to explicitly set parameters that are essential for you.

For a complete description of the File component see:
http://camel.apache.org/file.html


Greets,
Geert.


>
> hi
>
> i deployed a camel routing service in servicemix.  here is my code
>                        try {
>                               context.addRoutes(new RouteBuilder() {
>                                public void configure() {
>
> from("http://localhost/testservice/resources/1";).to("file:/target/");
>                                } });
>                          } catch (Exception e) {
>                               e.printStackTrace();
>                         }
>                        try{
>                             context.start();
>                              Thread.sleep(5000);
>                               context.stop();
>                       }catch(Exception e){}
>
> while the program(servicemix) is running it is invoked the web service
> (http://localhost/testservice/resources/1) specified in the from() method,
> and the output of the xml values are stored inside the target folder.
>  my xml output will be like this, <?xml version=1.1><root> <test>my sample
> service </test></root>
>  Problem:
>    It creates multiple text file along with the xml value inside the
> targer
> folder. when ever i execute the program it will put around 100 text files
> in
> the target folder . i want to store it in a single text file. how do i
> overcome this issue.
>
> --
> View this message in context:
> http://servicemix.396122.n5.nabble.com/Camel-Route-How-to-avoid-Multiple-files-in-target-folder-tp3244637p3244637.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>
>


Reply via email to