You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by jonathanq <jq...@abebooks.com> on 2010/06/30 01:46:33 UTC

Camel 2.3.0 - File Endpoint with delete=true and moveFailed doesn't move failed files

I am using Camel 2.3.0 - I have a file endpoint that is configured with
delete=true and moveFailed=error.  Yet when an error occurs, it does not
move it to a failed directory, and instead keeps re-trying the exchange.

Here is a route that shows my setup:

public void configure() throws Exception {

onException().process(myErrorProcessor).to("mock:error");

from("file://c:\\input?delete=true&moveFailed=error").process(someProcessor).unmarshal().xstream().to("mock:result")

}

The processor just does a simple transformation - however I am feeding it
invalid XML so that the unmarshal will fail.  The error processor is
executed, but when it completes and sends its error message to "mock:error"
- the whole route starts again.

I removed the "delete=true" so it was just:
"file://c:\\input?moveFailed=error".  Then when an error occurs, it moves
the file to error subdirectory.  And the completed files go to ".camel".

I don't want to have to remove the completed files manually so I changed the
route to:

"file://c:\\input?delete=true"
Now - regardless of whether an exception occurs - the input file is deleted.

It seems to be that the combination of both "delete=true" and
"moveFailed=error" seems to cause the route to keep re-trying indefinately,
but on their own - they work exactly as advertised.

Is the delete=true supposed to only moved completed (successfully) files? 
The documentation only says it will delete them after they are processed
(doesn't say if they succeeded or not).

I added a handled(true) on my exception route - and then it just deletes the
file and never moves it to the error folder.

I can remove the delete=true and my process will do what I want - however
then I have to make a manual step later to delete the contents of the .camel
folder for the ones that did work.  And I don't want to do that, seems to me
the delete=true should handle that.

Jonathan 
-- 
View this message in context: http://camel.465427.n5.nabble.com/Camel-2-3-0-File-Endpoint-with-delete-true-and-moveFailed-doesn-t-move-failed-files-tp511964p511964.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel 2.3.0 - File Endpoint with delete=true and moveFailed doesn't move failed files

Posted by ebinsingh <eb...@VerizonWireless.com>.
I am using the Camel Version 2.8.1 and looks like having delete and
onException together does not work.
I have a invalid XML (With lots of closing tags missing). The valid XML's
are processed and sent to the queue, but the invalid XML is not processed,
but all the files get deleted.

I am new to Camel, so please let me know if I am missing something here.

Code sample:

		try{
			onException(Exception.class)
            .maximumRedeliveries(3)
            .handled(true)
            .to("file:C:\\camelProject\\data\\error");
			
	    	//ExecutorService executor = Executors.newFixedThreadPool(5);
	        from("file:C:\\camelProject\\data\\inbox?delete=true")
	        .process(new Processor() {
						@Override
						public void process(Exchange exchange) throws Exception {
							processMessage(exchange);
						}
					}).to("seda:orders");
	        
	        from("seda:orders")
	        .choice()
	            .when(header("CamelFileName").contains("incomingOrders"))
                    .to("jms:queue:test_request_1",
"file:C:\\camelProject\\data\\outbox")
	            .when(header("CamelFileName").contains("outgoingOrders"))
	                .to("jms:queue:test_request_2",
"file:C:\\camelProject\\data\\outbox");
		}catch(Exception ex){
			ex.printStackTrace();
		}

--
View this message in context: http://camel.465427.n5.nabble.com/Camel-2-3-0-File-Endpoint-with-delete-true-and-moveFailed-doesn-t-move-failed-files-tp511964p4900256.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel 2.3.0 - File Endpoint with delete=true and moveFailed doesn't move failed files

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

I have created a ticket
https://issues.apache.org/activemq/browse/CAMEL-2879

As it is in fact an oversight. We should support having Camel to
delete the files if OK and if ERROR then move the files to a selected
directory.
Its in fact a common approach.


On Wed, Jun 30, 2010 at 5:17 AM, Willem Jiang <wi...@gmail.com> wrote:
> Hi,
>
> I just checked the code of Camel File component, you can't specify the
> delete and move (moveFailed) option at the same time, as current Camel file
> component didn't support these two strategy at same time.
>
> I think you can do some work around by using onException() with the delete
> option, like this :
>
> onException(IllegalArgumentException.class).useOriginalMessage().to("file://target/failed/error");
> from("file://target/failed?delete=true") ....
>
> Willem
> ----------------------------------
> Apache Camel, Apache CXF committer
> Open SOA http://www.fusesource.com
> Blog http://willemjiang.blogspot.com
> Tiwtter http://twitter.com/willemjiang
>
> jonathanq wrote:
>>
>> I am using Camel 2.3.0 - I have a file endpoint that is configured with
>> delete=true and moveFailed=error.  Yet when an error occurs, it does not
>> move it to a failed directory, and instead keeps re-trying the exchange.
>>
>> Here is a route that shows my setup:
>>
>> public void configure() throws Exception {
>>
>> onException().process(myErrorProcessor).to("mock:error");
>>
>>
>> from("file://c:\\input?delete=true&moveFailed=error").process(someProcessor).unmarshal().xstream().to("mock:result")
>>
>> }
>>
>> The processor just does a simple transformation - however I am feeding it
>> invalid XML so that the unmarshal will fail.  The error processor is
>> executed, but when it completes and sends its error message to
>> "mock:error"
>> - the whole route starts again.
>>
>> I removed the "delete=true" so it was just:
>> "file://c:\\input?moveFailed=error".  Then when an error occurs, it moves
>> the file to error subdirectory.  And the completed files go to ".camel".
>>
>> I don't want to have to remove the completed files manually so I changed
>> the
>> route to:
>>
>> "file://c:\\input?delete=true"
>> Now - regardless of whether an exception occurs - the input file is
>> deleted.
>>
>> It seems to be that the combination of both "delete=true" and
>> "moveFailed=error" seems to cause the route to keep re-trying
>> indefinately,
>> but on their own - they work exactly as advertised.
>>
>> Is the delete=true supposed to only moved completed (successfully) files?
>> The documentation only says it will delete them after they are processed
>> (doesn't say if they succeeded or not).
>>
>> I added a handled(true) on my exception route - and then it just deletes
>> the
>> file and never moves it to the error folder.
>>
>> I can remove the delete=true and my process will do what I want - however
>> then I have to make a manual step later to delete the contents of the
>> .camel
>> folder for the ones that did work.  And I don't want to do that, seems to
>> me
>> the delete=true should handle that.
>>
>> Jonathan
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Camel 2.3.0 - File Endpoint with delete=true and moveFailed doesn't move failed files

Posted by Willem Jiang <wi...@gmail.com>.
Hi,

I just checked the code of Camel File component, you can't specify the 
delete and move (moveFailed) option at the same time, as current Camel 
file component didn't support these two strategy at same time.

I think you can do some work around by using onException() with the 
delete option, like this :

onException(IllegalArgumentException.class).useOriginalMessage().to("file://target/failed/error");
from("file://target/failed?delete=true") ....

Willem
----------------------------------
Apache Camel, Apache CXF committer
Open SOA http://www.fusesource.com
Blog http://willemjiang.blogspot.com
Tiwtter http://twitter.com/willemjiang

jonathanq wrote:
> I am using Camel 2.3.0 - I have a file endpoint that is configured with
> delete=true and moveFailed=error.  Yet when an error occurs, it does not
> move it to a failed directory, and instead keeps re-trying the exchange.
> 
> Here is a route that shows my setup:
> 
> public void configure() throws Exception {
> 
> onException().process(myErrorProcessor).to("mock:error");
> 
> from("file://c:\\input?delete=true&moveFailed=error").process(someProcessor).unmarshal().xstream().to("mock:result")
> 
> }
> 
> The processor just does a simple transformation - however I am feeding it
> invalid XML so that the unmarshal will fail.  The error processor is
> executed, but when it completes and sends its error message to "mock:error"
> - the whole route starts again.
> 
> I removed the "delete=true" so it was just:
> "file://c:\\input?moveFailed=error".  Then when an error occurs, it moves
> the file to error subdirectory.  And the completed files go to ".camel".
> 
> I don't want to have to remove the completed files manually so I changed the
> route to:
> 
> "file://c:\\input?delete=true"
> Now - regardless of whether an exception occurs - the input file is deleted.
> 
> It seems to be that the combination of both "delete=true" and
> "moveFailed=error" seems to cause the route to keep re-trying indefinately,
> but on their own - they work exactly as advertised.
> 
> Is the delete=true supposed to only moved completed (successfully) files? 
> The documentation only says it will delete them after they are processed
> (doesn't say if they succeeded or not).
> 
> I added a handled(true) on my exception route - and then it just deletes the
> file and never moves it to the error folder.
> 
> I can remove the delete=true and my process will do what I want - however
> then I have to make a manual step later to delete the contents of the .camel
> folder for the ones that did work.  And I don't want to do that, seems to me
> the delete=true should handle that.
> 
> Jonathan