类 SimpleMailMessageItemWriter

  • 所有已实现的接口:
    ItemWriter<org.springframework.mail.SimpleMailMessage>, org.springframework.beans.factory.InitializingBean

    public class SimpleMailMessageItemWriter
    extends java.lang.Object
    implements ItemWriter<org.springframework.mail.SimpleMailMessage>, org.springframework.beans.factory.InitializingBean

    A simple ItemWriter that can send mail messages. If it fails there is no guarantee about which of the messages were sent, but the ones that failed can be picked up in the error handler. Because the mail protocol is not transactional, failures should be dealt with here if possible rather than allowing them to be rethrown (which is the default).

    Delegates the actual sending of messages to a MailSender, using the batch method MailSender.send(SimpleMailMessage[]), which normally uses a single server connection for the whole batch (depending on the implementation). The efficiency of for large volumes of messages (repeated calls to the item writer) might be improved by the use of a special MailSender that caches connections to the server in between calls.

    Stateless, so automatically restartable.

    从以下版本开始:
    2.1
    作者:
    Dave Syer
    • 方法概要

      所有方法 实例方法 具体方法 
      修饰符和类型方法说明
      voidafterPropertiesSet()
      Check mandatory properties (mailSender).
      voidsetMailErrorHandler​(MailErrorHandler mailErrorHandler)
      The handler for failed messages.
      voidsetMailSender​(org.springframework.mail.MailSender mailSender)
      A MailSender to be used to send messages in write(List).
      voidwrite​(java.util.List<? extends org.springframework.mail.SimpleMailMessage> items)
      Process the supplied data element.
      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 方法详细资料

      • setMailSender

        public void setMailSender​(org.springframework.mail.MailSender mailSender)
        A MailSender to be used to send messages in write(List).
        参数:
        mailSender - The MailSender to be used.
      • afterPropertiesSet

        public void afterPropertiesSet()
                                throws java.lang.IllegalStateException
        Check mandatory properties (mailSender).
        指定者:
        afterPropertiesSet 在接口中 org.springframework.beans.factory.InitializingBean
        抛出:
        java.lang.IllegalStateException - if the mandatory properties are not set
        另请参阅:
        InitializingBean.afterPropertiesSet()
      • write

        public void write​(java.util.List<? extends org.springframework.mail.SimpleMailMessage> items)
                   throws org.springframework.mail.MailException
        从接口复制的说明: ItemWriter
        Process the supplied data element. Will not be called with any null items in normal operation.
        指定者:
        write 在接口中 ItemWriter<org.springframework.mail.SimpleMailMessage>
        参数:
        items - the items to send
        抛出:
        org.springframework.mail.MailException
        另请参阅:
        ItemWriter.write(List)