I have what I consider to be a very common scenario. I have an account system that is managed through Apache Camel. When something goes wrong, I would like to receive an email notification sent to the administrator.
After familiarizing myself with Camel exception handling, I came up with the following: (inside my Spring XML)
<errorHandler id="deadChannel" type="DeadLetterChannel" deadLetterUri="direct:invoice-error"> <redeliveryPolicy maximumRedeliveries="2" redeliveryDelay="1000" backOffMultiplier="2" useExponentialBackOff="true" /> </errorHandler> <route id="invoices-with-errors"> <from uri="direct:invoice-error" /> <bean ref="emailAlert" method="handleProblematicInvoice" /> <to uri="smtp://{{errormail.host}}?to={{errormail.to}}&subject={{errormail.subject}}&from={{errormail.from}};debugMode=true;connectionTimeout=5000" /> </route>
This works OK for my use case. When any exception is sent, the actual email is sent to a specific address.
However, to check for cases in the window, I stopped the internal mail server to find out what was happening. I expected Camel to try emailing and stop trying after 5 seconds (as specified in the connectionTimout parameter in the smpt url)
At the same time, even though the WHOLE Camel app freezes! This is simply unacceptable! I can not guarantee that the mail server will be 100%.
Am I missing something? Should I completely abandon the idea of email alerts or do you need another special option for NOT when the mail server is disconnected?
Answer
Line
debugMode=true;connectionTimeout=5000
it should be
debugMode=true&connectionTimeout=5000
source share