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

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

问题描述

我正在尝试使用简单的方法发送电子邮件,这是非常慢的。有些人告诉我通过Asynchronous 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.

这是我的旧问题电子邮件代码使Java代码中的代码更慢MVC

任何人指导这是什么,以及如何使发送电子邮件更快

can anyone guide on this what is that and how will it make sending email faster

推荐答案

设置一个使用线程池执行器的Executor bean您的弹簧上下文,并使用它来排列将发送电子邮件的工作项。然后它将以异步方式在线程池线程上调度,因此您的请求线程将不会阻止。

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天全站免登陆