How would one retrieve the 'to', 'from', ''subject', 'hmlVar' values of an activiti mailtask via either a 'java class start or end listener on the given mailtask? If notpossible, what ate the alternatives? I am able to capture an email failure with use of the ignoreexception setting, but i need to identfy the pertinent elements fo the given problematic email.
Reading your question, I think you're asking "if my email task fails, I'd like to capture its details".
The email task is pretty simple as is right now.
So I'd recommend you to write up your own Email Task class using Java Service Task and implement error handling patterns within. With your own Email Task, you'd have total control over the email task, its configuration settings and how it should behave if errors occur.
In your case, what problems are you having with Email Task out-of-the-box?
Yes, I could replace the existing out of the box nail tasks but I'm looking to minimize the level of effort for addressing an issue at hand (which I'll explain momentarily). There are multiple workflow templates, each with multiple email tasks, for which I need to work with. They all currently implement the same start and end listeners to perform various actions. I thought I would be able to update one listener to capture the desired data for further processing. So, I'm not clear if you are saying it is not possible to capture this data?
To your question on what the issue is that is driving this question.........
The mail tasks are sporadically failing and thus rolling back to the previous user task. The failures are attributed to mailhost being unavailable ( usually too busy).. I have no control on the mailhost availability, I've been told by IT to simply re-send. The retry is set to the default 3, but even that on occasions is not enough . To avoid the rollback effect of a failed mailtask, I've set the ignoreException to true and I am capturing the error msg thrown in the post task listener, where I subsequently send an email (via a database procedure call with task variable inputs) to the admin notifying about the email failure. But, the desire is to successfully send the intended email .
My use of the ignoreException has actually made a bad situation worse, as it appears if first attempt fails there are no retries.
Perhaps there is a way to increase the retries, specific to the given task, if it fails after the default 3? But I would still ultimately need to have the ignoreexception kick in if the max retries is hit to gracefully
handle the final failure and allow flow to move on to next usertask. Any ideas on how I would approach that or any other suggestions aside from using a different means of sending Emails?
Awesome response! Appreciate it. I understand your use case now. Let me try some experiments on my end and I will get back to you.
There are multiple workflow templates, each with multiple email tasks, for which I need to work with. They all currently implement the same start and end listeners to perform various actions. I thought I would be able to update one listener to capture the desired data for further processing. So, I'm not clear if you are saying it is not possible to capture this data?
It would be super helpful if you can create a unit test that represents your current implementation (I'm not quite getting it based on this description e.g. what are start and end listeners? what do you mean by updating a listener? etc.).
Given the significant number of email tasks in a given workflow and the level of effort to implement the suggestion of parsing the xml to retrieve the desired data, I have decided to replace the Activiti out-of-the-box mail task with execution listeners to send email