问题
I need to send multiple emails to many users in my application using Spring Batch. I am new to Spring Batch. Need some pointers for it.
回答1:
This Question is way to vague, so my answer will also have to be very vague.
Spring Batch is based on Spring, so you can just use Spring's Email Support, read the corresponding section from the reference manual
In Spring Batch, there are different places where you can register listeners, e.g.
- Jobs
- Steps
- Chunks
Each of these listeners can be a custom implementation that sends emails using the Techniques described in the link above, using MailSender
and SimpleMailMessage
.
You could of course also implement an Email-based ItemWriter, but I'd hardly call that a good practice.
回答2:
Moreover, you could write a Mail Service used by your application.
Then, use this service as a Processor in your batch : Reusing Existing Services
来源:https://stackoverflow.com/questions/5089283/how-to-send-multiple-emails-using-spring-batch