The smtp Apache Camel component hangs on the entire bus if the mail server is disabled

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)

<!-- General retrasmission policy set to 3 times --> <errorHandler id="deadChannel" type="DeadLetterChannel" deadLetterUri="direct:invoice-error"> <redeliveryPolicy maximumRedeliveries="2" redeliveryDelay="1000" backOffMultiplier="2" useExponentialBackOff="true" /> </errorHandler> <!-- Problematic invoices create email alerts to the administrator --> <route id="invoices-with-errors"> <from uri="direct:invoice-error" /> <bean ref="emailAlert" method="handleProblematicInvoice" /> <to uri="smtp://{{errormail.host}}?to={{errormail.to}}&amp;subject={{errormail.subject}}&amp;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&amp;connectionTimeout=5000 
+4
source share
1 answer

Camel uses the Java Mail API and is thus under its auspices how long it takes to send an email or find out something is wrong.

You can use wireTap to send email asynchronously. Then the error handler thread will no longer be blocked for a longer time http://camel.apache.org/wire-tap

+1
source

All Articles