如何使用异步API发送电子邮件在Java [英] How to send email in java using asynchronous API

查看:505
本文介绍了如何使用异步API发送电子邮件在Java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图发送邮件使用简单的方法电子邮件,这是非常慢。有的告诉我通过异步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屋!

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