类 SimpleMailMessageItemWriter
- java.lang.Object
- org.springframework.batch.item.mail.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 methodMailSender.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 specialMailSender
that caches connections to the server in between calls.Stateless, so automatically restartable.
- 从以下版本开始:
- 2.1
- 作者:
- Dave Syer
构造器概要
构造器 构造器 说明 SimpleMailMessageItemWriter()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
afterPropertiesSet()
Check mandatory properties (mailSender).void
setMailErrorHandler(MailErrorHandler mailErrorHandler)
The handler for failed messages.void
setMailSender(org.springframework.mail.MailSender mailSender)
AMailSender
to be used to send messages inwrite(List)
.void
write(java.util.List<? extends org.springframework.mail.SimpleMailMessage> items)
Process the supplied data element.
构造器详细资料
SimpleMailMessageItemWriter
public SimpleMailMessageItemWriter()
方法详细资料
setMailSender
public void setMailSender(org.springframework.mail.MailSender mailSender)
AMailSender
to be used to send messages inwrite(List)
.- 参数:
mailSender
- TheMailSender
to be used.
setMailErrorHandler
public void setMailErrorHandler(MailErrorHandler mailErrorHandler)
The handler for failed messages. Defaults to aDefaultMailErrorHandler
.- 参数:
mailErrorHandler
- the mail error handler to set
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)