如何使用异步API发送电子邮件在Java [英] How to send email in java using asynchronous API
问题描述
我试图发送邮件使用简单的方法电子邮件,这是非常慢。有的告诉我通过异步API发送电子邮件。
I was trying to send email using simple method and it was very slower. and some told me to send email via Asynchronous API.
这是我的老问题,<一个href=\"http://stackoverflow.com/questions/5288043/email-$c$c-makes-the-$c$c-slower-in-java-spring-mvc\">Email code使得code较慢的Java中的Spring MVC
可以在这个指南的人那是什么,以及如何将使其更快发送电子邮件
can anyone guide on this what is that and how will it make sending email faster
推荐答案
设置,在你的Spring上下文中使用一个线程池遗嘱执行人,并用它来排队一个工作项,将发送电子邮件的执行人豆。它然后将一个线程池线程异步分派,因此您的要求线程不会阻塞。
Setup an Executor bean that uses a thread pool executor in your spring context and use it to enqueue a work item that will send the email. It will then be dispatched on a thread pool thread asynchronously and therefore your request thread will not block.
这篇关于如何使用异步API发送电子邮件在Java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!