How to send multiple emails using spring batch

6.7k Views Asked by At

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.

2

There are 2 best solutions below

0
On

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.

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.

0
On

Moreover, you could write a Mail Service used by your application.

Then, use this service as a Processor in your batch : Reusing Existing Services