Announcement Announcement Module
No announcement yet.
Using JavaMailSender batch sending capabilities Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using JavaMailSender batch sending capabilities


    I would like to use the batch sending capabilities of the JavaMailSender, but I see a problem regarding the failed messages: throwing the same exception for connection related problems and problems regarding messages at the individual level does not seem particularly handy.

    My catch clause would have to test the exception for getFailedMessages() returning null / or not, rather than just letting a catch clause filter the appropriate exception type.

    Furthermore, I think that throwing an exception in the case of failure at message level is counter-intuitive: usually, in the case of an exception being thrown, users would expect the whole batch as being in error, while several mails may have been sent. I know mail relays are not transactionnal ,and that it would therefore be impossible to ensure a all or nothing behavior.

    What would be nice would be to provide a callback to handle errors at individual message level if desired (current behavior would be kept by default).

    I would also like to get the ability to inject my own code when the transport is connected, a la HibernateCallback. Nasty JavaMail stuff would be abstracted by helper class:

    JavaMailHelper.sendMessage(transport, mimeMessagePreparator);