开发者

Sending multiple emails efficiently

I have reached a point where I will have to send email notifications to my users, fro any event they have subscribed to. My service is not large, but nothing stops it from becoming one, thus I would like to be prepared.

Currently, I am handling those emails using Spring's mail sender in a fairly synchronous manner (grabbing a bunch of subscribed email addresses from a collection and sending them a mail) However, one can see how unusable this approach may soon become. Thus I am striving for a little bit more parallelism.

Multiple threads may help the situation unless there are too many of them at the same time. I guess |I will need something like an in-memory queue, which could send batches of emails at certain intervals, opening a new thread. Threads which are finished will eb collected in 开发者_如何学JAVAa thread pool and reused.

Suggestions? Perhaps my approach is too complex. Perhaps Spring already offers a way to alleviate the blocking and synchronism. I'd be glad to know.


Rather than send one email to each user, just send a single email to all of the users at once. In other words, make one mail and add every user to the destination list. Then your SMTP server will worry about duplicating it and sending copies to each person.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜