Hi Mark
Unfortunately it is still not working. I have done:
Code:
<chain input-channel="errorChannel" output-channel="errorOutChannel">
<transformer ref="errorTransformer" method="transformError" />
</chain>
<mail:header-enricher from="${mailFrom}" to="${mailTo}" subject="${mail.subject}" overwrite="false" input-channel="errorOutChannel" output-channel="errorMailOutChannel"/>
<!-- Mail sending error -->
<mail:outbound-channel-adapter channel="errorMailOutChannel" mail-sender="mailSender" />
and tried
Code:
<beans:bean id="errorTransformer" class="com.amin.luceneindexsi.index.integration.transformer.ErrorTransformer" />
<chain input-channel="errorChannel" output-channel="errorOutChannel">
<transformer ref="errorTransformer" method="transformError" />
<mail:header-enricher from="${mailFrom}" to="${mailTo}" subject="${mail.subject}" overwrite="false"/>
</chain>
But both do not work. I'm not sure which one is the best approach to be honest. My error to mail transformer has the following:
Code:
public class ErrorTransformer {
public MailMessage transformError(ErrorMessage errorMessage) {
Message<?> failedMessage = ((MessagingException) errorMessage.getPayload()).getFailedMessage();
Throwable cause = ((MessagingException) errorMessage.getPayload()).getCause();
IndexingException indexingException = new IndexingException(cause,failedMessage.getPayload());
SimpleMailMessage mailMessage = new SimpleMailMessage();
message.append("An exception occured while performing an index operation").append(", the following provides more details:\n");
message.append("Exception message:\n").append(indexingException.getExceptionThrown().getMessage() + "\n");
message.append("\n\n");
message.append("Exception occured:\n");
message.append(indexingException.getExceptionThrown().getStackTrace()[0].toString());
message.append("\n\n");
message.append("Message failed:\n").append(indexingException.getPayLoad().toString());
mailMessage.setText(message.toString());
return mailMessage;
}
I presume the enricher should add the to and from settings to the mailMessage.
The process only works when I add the "to" and "from" the mail message itself.
Any help would be appreciated.
Cheers