cancel
Showing results for 
Search instead for 
Did you mean: 

How to handle mail host unavailability exception

lossril
Champ in-the-making
Champ in-the-making
Hello.
We've got my e-mail server settings configured for the Activiti webapp we're using and mail tasks are doing fine, but there's a problem.

Sometimes it goes offline (our admins are doing some maitenance from time to time) and if Activiti tries to send an e-mail when the server is unavailable, webapp throws an exception and does a rollback to the last usertask, throwing an exception originating to Apache Commons Mail classes - you can see the stack trace in the attachment file. It does not happen frequently but we need a way to handle it properly.

Is there a way to handle this exception correctly and without those nasty rollbacks? Does boundary error event on the mail task catch it? I've found out that there is a field 'ignoreException' in mail task description which may be set to 'true' and the exception will be ignored but this makes failure handling complicated - in the case I should check the variable with failure message and litter BPMN definitions. Does Activiti have some system-wide setting on ignoring email failures?
1 REPLY 1

hari
Star Contributor
Star Contributor
Hi,

We have a similar situation in our application and the way we handled it is as below.
- In the service task which sends out an email, I will have a try-catch block and when an exception occurs, I put the stack trace(trim to 4k chars) into a process variable and set a flag in process variables to true. And when this service task gets completed, I check for the flag variable and if its true, I send these exception details over to a user/team with an option to retry. So when they do so,  I will hit the email service task again.
When the email service task executes without any exception, I set the flag to false and hence the flow takes a happy path.
I hope this helps you in your case.