cancel
Showing results for 
Search instead for 
Did you mean: 

How can I manage errors generated by MailTask?

supermarco
Champ in-the-making
Champ in-the-making
Hello all,
during my activiti-process I have an automatic MailTask, but if I have no smtp-server the process makes an error.
How can I manage this error? It haven't be a blocking-error!
I attach an image to clarify my problem.

Thank you.
10 REPLIES 10

trademak
Star Contributor
Star Contributor
Hi,

What's the reason for adding a mail task if you don't have a SMTP server?

Best regards,

supermarco
Champ in-the-making
Champ in-the-making
Hi,

What's the reason for adding a mail task if you don't have a SMTP server?

Best regards,
Hi,

for instance, in production-environment there is a SMTP server, in develop-environment there's no SMTP server.
Another reason can be customer doesn't want this mail-feature while testing o in the first period of operation.
I can't draw two different processes, especially if they are very complex!

Can you help me?

trademak
Star Contributor
Star Contributor
Hi,

No it doesn't make a lot of sense to me.
It would be very easy to setup a mail server during development. You could even use something like http://code.google.com/p/subethasmtp/ to make it even easier.
And otherwise you could easily change the mail task in a manual task during development. But I would go for a simple email server.

Best regards,

christoph_retti
Champ in-the-making
Champ in-the-making
I think this is a valid point because even in production mailservers can get into trouble, crash or maybe you just have problems connecting to the mailserver
because there are problems on the network.

So I also would prefer the mail task to have at least an error exit so that one can decide

(a) to just ignore any errors or
(b) implement some strategy to come around this problem

Alternatively an additional configuration attribute "errorHandling" with the options

- ignore errors silently
- ignore errors but trace a warning
- take exit on error
- throw an exception on erro

could be implemented and let the modeller decide how to handle the situation.

  c

trademak
Star Contributor
Star Contributor
Hi,

The Mailtask is a very simple class, so a valid approach would be to implement your own mail service task where you can add the error handling you want.

Best regards,

dokmatik
Champ in-the-making
Champ in-the-making
Hi,

this is what I would do. It's kind of a workaround but might work. I am going to try it because I am kind of facing the same problem.

In your ProcessEngineConfiguration you are able to add pre- or post parse listeners, which will be notified when your BPMN 2.0 files are parsed. That said, I should be able to react to parse events of <serviceTask…>-elements which are usually used for mail service tasks too.

Check the

org.activiti.engine.impl.bpmn.parser.BpmnParseListener.parseScriptTask(Element scriptTaskElement, ScopeImpl scope, ActivityImpl activity);
method. You should be able to dynamically replace the default "activityBehaviour" property and set your own implementation. That way I should - hopefully - be able to replace the default MailAcitivtyBehaviour implementation.

Will inform you again if this is going to work.

Regards
dokmatik

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
This might work, but WHY not simply start a very simple embeded mailserver in test/development/…

dokmatik
Champ in-the-making
Champ in-the-making
Please dont get me wrong.
I am fully fine with setting up a simple test mail server in dev environments.

However, in my case a more finegrained control over ActivityBehaviours is needed. So since we work with aspects around ActivityBehaviour / JavaDelegate beans it comes very handy to have ones own MailActivityBehaviour. The default implementation cannot be simply decorated or intercepted since instantiation occurs hardcoded in the BpmnParser.

regards
dokmatik

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
ah… ok, yes if it is a more generic issue… sounds fair.