Spring 邮件关闭微服务
Spring Mail shutting down micro service
我有一个带有 Spring Boot 2.4.2 的微服务,它使用 JavaMailSender 发送电子邮件。
问题是,如果我没有互联网 and/or 电子邮件配置错误,Eureka 服务器上的微服务注册为 DOWN 并且不回答我的请求。我的微服务不只是为了电子邮件和 can/need 在没有外部连接的情况下工作,我如何防止电子邮件杀死我的微服务?
我的属性:
## INFORMACOES EMAIL
spring.mail.properties.mail.smtp.connecttimeout=5000
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.starttls.required=true
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.connectiontimeout=5000
spring.mail.properties.mail.smtp.timeout=5000
spring.mail.properties.mail.smtp.writetimeout=5000
spring.mail.host=smtp.gmail.com
spring.mail.port=587
spring.mail.username=Wrong email (For debug porpuses)
spring.mail.password=NOT HERE...
问题是,当您配置邮件发件人时,Spring Actuator 会自动创建一个 MailHealthIndicator。
您可以在 application.properties
或系统 属性 或环境变量中将 属性 management.health.mail.enabled
设置为 false
来禁用它。
你唯一要考虑的是如果无法访问邮件服务你会做什么,也许将请求存储在数据库或队列中...
我有一个带有 Spring Boot 2.4.2 的微服务,它使用 JavaMailSender 发送电子邮件。 问题是,如果我没有互联网 and/or 电子邮件配置错误,Eureka 服务器上的微服务注册为 DOWN 并且不回答我的请求。我的微服务不只是为了电子邮件和 can/need 在没有外部连接的情况下工作,我如何防止电子邮件杀死我的微服务?
我的属性:
## INFORMACOES EMAIL
spring.mail.properties.mail.smtp.connecttimeout=5000
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.starttls.required=true
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.connectiontimeout=5000
spring.mail.properties.mail.smtp.timeout=5000
spring.mail.properties.mail.smtp.writetimeout=5000
spring.mail.host=smtp.gmail.com
spring.mail.port=587
spring.mail.username=Wrong email (For debug porpuses)
spring.mail.password=NOT HERE...
问题是,当您配置邮件发件人时,Spring Actuator 会自动创建一个 MailHealthIndicator。
您可以在 application.properties
或系统 属性 或环境变量中将 属性 management.health.mail.enabled
设置为 false
来禁用它。
你唯一要考虑的是如果无法访问邮件服务你会做什么,也许将请求存储在数据库或队列中...