camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From turp1twin <jeff.tur...@ecloser.net>
Subject Re: Error Handling
Date Tue, 12 May 2009 04:31:38 GMT

Hi Claus,

Thanks so much for the quick response! This helps me very much! Yes,
basically, if the sending the email fails, I just want to log the error and
end the route. I want the File consumer to complete and move/delete the
file, since a new file will be created and processed at a later time with
the same data since the FTP failed. Anyways, the info you provided below
will be very helpful. I have created a Processor to handle the errors this
evening, and that seems to work, however, I think the try catch semantics of
the Java DSL will be cleaner. Should I pull down the 2.0-M2 snapshot?
Cheers!


Jeff


Claus Ibsen-2 wrote:
> 
> Hi
> 
> Error handling is hard, especially for non transactional transports
> such as File / FTP and the likes.
> 
> From what I understand from your description is that you want to poll
> files and upload them to SFTP.
> And in case this fails an email should be sent. And if this email
> fails then it should ????
> 
> If you where doing this with regular Java you would probably use the
> try .. catch .. finally.
> And they also exists in Camel DSL
> 
> .doTry()
>    // send file to SFTP
> .doCatch(Exception)
>    .doTry()
>    // send an email
>    .doCatch()
>    // log failed to send email
>    .end()
> .end()
> 
> And they support handled(true) as well.
> See more here
> http://davsclaus.blogspot.com/2009/04/on-road-to-camel-20-try-catch-finally.html
> 
> And here:
> http://camel.apache.org/try-catch-finally.html
> 
> However try .. catch .. finally have been overhauled in Camel 2.0m2 so
> you have to wait for this release or use SNAPSHOT if you want.
> 
> 
> Also the general error handling in Camel 2.0 have had a major overhaul
> as well. In fact I do believe that the problem with error handling,
> when doing error handling has been fixed in 2.0m2 (SNAPSHOT) as well.
> 
> So in your case if the SMTP failed then it would not "catch this" but
> it should be fixed in 2.0m2.
> 
> 
> 
> If you want to avoid consuming the same file again then use the
> Idempotent Consumer EIP
> http://camel.apache.org/idempotent-consumer.html
> 
> 
> 
> 
> On Tue, May 12, 2009 at 1:30 AM, turp1twin <jeff.turpin@ecloser.net>
> wrote:
>>
>> I am new to Camel and am having a tough time getting my route to work
>> properly. That being said, it is entirely possible that I am being a
>> moron
>> and have missed something simple.... However, I have searched the mailing
>> list and have not found the answer I am looking for. Any help would be
>> appreciated. I am using Camel 2.0-M1 and I am trying to test my various
>> error handling scenarios. I am using a Java DSL with various endpoints
>> configured in my Spring camel-context.xml.
>>
>> Endpoints:
>>
>> <camel:endpoint id="filePollingDir"
>> uri="file:///Users/xxxxx/temp/polldir/"/>
>>
>> <camel:endpoint id="sFtpDestination"
>>
>> uri="sftp://R098697@sftp.someserver.com/upload?password=xxxxxx&amp;knownHostsFile=/Users/xxxxx/.ssh/known_hosts"/>
>>
>> <camel:endpoint id="failedTransferSmtp"
>> uri="smtp://smtp.someserver.net?to=user@mymail.net&amp;from=admin@mymail.net"/>
>>
>> Route definition:
>>
>> from(getEndpoint("filePollingDir")).onException(Exception.class).maximumRedeliveries(0).handled(true).end()
>> .to(getEndpoint("sFtpDestination")).onException(Exception.class).maximumRedeliveries(2).handled(true)
>> .to(getEndpoint("failedTransferSmtp")).onException(Exception.class).maximumRedeliveries(0).handled(true).end();
>>
>>
>> Basically what I am trying to achieve is that if the SFTP producer fails
>> I
>> want to send an email notifying a user that the transfer failed. I also
>> want
>> to handle the case where the smtp producer might also fail. I am getting
>> to
>> the SMTP endpoint (failedTransferSmtp) just fine, however, when it fails
>> (as
>> intended for this particular test) it causes the "filePollingDir"
>> consumer
>> to rollback and consume the source file again. This continues in a
>> loop...
>> Is this behavior intended? If so, can I configure the consumer to stop
>> consuming the same file again? Again, I might be missing something
>> simple,
>> but any help would be appreciated. Cheers!
>>
>> Jeff
>>
>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Error-Handling-tp23493625p23493625.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> Claus Ibsen
> Apache Camel Committer
> 
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
> Apache Camel Reference Card:
> http://refcardz.dzone.com/refcardz/enterprise-integration
> Interview with me:
> http://architects.dzone.com/articles/interview-claus-ibsen-about?mz=7893-progress
> 
> 

-- 
View this message in context: http://www.nabble.com/Error-Handling-tp23493625p23496008.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Mime
View raw message