为什么JMS通过Java Mail发送邮件 [英] Why JMS to send mail by Java Mail

查看:175
本文介绍了为什么JMS通过Java Mail发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

场景1:


  1. 在服务器中设置JMS队列

  2. 将消息发送到Producer的Java代码
    创建一个JMS Producer,在调用时,应该接收电子邮件数据(subject,body,to,cc等)并将其发布到步骤1中的Queue设置

  3. 创建一个JMS使用者,它订阅在步骤1中创建的队列,其onMessage应该调用JavaMail API来发送电子邮件。

场景2:


  • 直接调用JavaMail API发送电子邮件。

我知道如何使用以及JMS和Java Mail正在做什么.Thing是我们必须从场景2开始的原因发送邮件至情景1。最初我们做了场景2.现在我们正在使用场景1.从大应用程序的不同部分发送邮件所以我们使用JMS队列,将有来自队列的消费者发送邮件。请帮助我理解。

I know about how to use and what JMS and Java Mail are doing.Thing is why we have to go from Scenario 2 to Scenario 1 for sending mails.Initially we did Scenario 2.Now we are using Scenario 1.From Different parts of the Big Application are sending mails so we use JMS Queue ,there will be Consumer of Queue from there sending mails.Please help me to understand.

推荐答案

您将在大型应用程序中使用此机制有两个原因:

You would use this mechanism in a large application for 2 reasons:

1)您不希望您的客户端必须等待邮件发送。

1) You don't want your clients to have to wait for the mail to be sent.

2)如果因任何原因失去与邮件服务器的连接,你不想丢失邮件。

2) You don't want to lose mails if you lose connectivity to your mail server for any reason.

这篇关于为什么JMS通过Java Mail发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆