类 MimeMessageItemWriter

  • 所有已实现的接口:
    ItemWriter<javax.mail.internet.MimeMessage>

    public class MimeMessageItemWriter
    extends java.lang.Object
    implements ItemWriter<javax.mail.internet.MimeMessage>

    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 JavaMailSender, using the batch method JavaMailSender.send(MimeMessage[]), 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 JavaMailSender that caches connections to the server in between calls.

    Stateless, so automatically restartable.

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

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

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

      • setJavaMailSender

        public void setJavaMailSender​(org.springframework.mail.javamail.JavaMailSender mailSender)
        A JavaMailSender to be used to send messages in write(List).
        参数:
        mailSender - service for doing the work of sending a MIME message
      • afterPropertiesSet

        public void afterPropertiesSet()
                                throws java.lang.IllegalStateException
        Check mandatory properties (mailSender).
        抛出:
        java.lang.IllegalStateException - if the mandatory properties are not set
        另请参阅:
        InitializingBean.afterPropertiesSet()
      • write

        public void write​(java.util.List<? extends javax.mail.internet.MimeMessage> 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<javax.mail.internet.MimeMessage>
        参数:
        items - the items to send
        抛出:
        org.springframework.mail.MailException
        另请参阅:
        ItemWriter.write(List)