|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.batch.item.mail.SimpleMailMessageItemWriter
public class SimpleMailMessageItemWriter
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.
Constructor Summary | |
---|---|
SimpleMailMessageItemWriter()
|
Method Summary | |
---|---|
void |
afterPropertiesSet()
Check mandatory properties (mailSender). |
void |
setMailErrorHandler(MailErrorHandler mailErrorHandler)
The handler for failed messages. |
void |
setMailSender(MailSender mailSender)
A MailSender to be used to send messages in write(List) . |
void |
write(List<? extends SimpleMailMessage> items)
Process the supplied data element. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SimpleMailMessageItemWriter()
Method Detail |
---|
public void setMailSender(MailSender mailSender)
MailSender
to be used to send messages in write(List)
.
mailSender
- public void setMailErrorHandler(MailErrorHandler mailErrorHandler)
DefaultMailErrorHandler
.
mailErrorHandler
- the mail error handler to setpublic void afterPropertiesSet() throws IllegalStateException
afterPropertiesSet
in interface InitializingBean
IllegalStateException
- if the mandatory properties are not setInitializingBean.afterPropertiesSet()
public void write(List<? extends SimpleMailMessage> items) throws MailException
ItemWriter
write
in interface ItemWriter<SimpleMailMessage>
items
- the items to send
MailException
ItemWriter.write(List)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |