开发者

How to use Spring as email storage

Pls can anyone tell me ho开发者_JS百科w to use spring as temporarily email storage? Basically i need to store email temporarily in memory if it couldn't connect to email server(reason like network error).then application should try to reconnect to the mail server.once it connect it should send email in memory.


Spring doesn't really have a solution for this use case.

There are a couple of options:

  1. Get an SMTP server setup on the localhost such that it will relay the message to the central instance. This removes the network connection between your application and the mail server hence should hopefully make the chance of not reaching it very small.
  2. Store the message in the DB, not ideal as if there is a network issue that prevented access to the mail server, there could easly be a network issue that effects db access. Also you will have to create some sort of retry process to resend the message every x minutes
  3. Post the message to a local persistant JMS Queue then have a message driven bean (or spring messaging container) remove the message and post it to the mail server

In my personal experience option 1. ussually gets me close enough to the level of service I need, but you will have to evalutate your own requirements.

I've actually seen option 3 implemented in a production system badly with a remote JMS broker. The important feature is that the JMS Broker is local and preferably inprocess so that there zero chance of a network blimp effecting the connection.


This isn't really a Spring question. What you're asking for is a mail sending mechanism that can queue sends on failure, with retries. You could, of course, create a bean with such capabilities, and wire it via Spring; it'd be very useful, I'd imagine, for some situations.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜