【问题标题】:grails asynchronous mail service errorgrails异步邮件服务错误
【发布时间】:2015-06-14 02:33:20
【问题描述】:

我们的系统正在使用 asynchronousMailService 在 Job 内发送电子邮件

log.debug 'Sending email to ' + emailTo
asynchronousMailService.sendMail {
    multipart true
    to emailTo.split("[,;]")
    bcc "test@bcc.com"
    from "test@from.com"
    subject "test subject"
    html(view:'/email/testTemplate', model: [test:  test])
    attachBytes testId +".pdf" , 'application/pdf', invoiceBytes
}
log.debug("Invoice email sent.")

使用以下 grails 配置:

grails {
    mail {
        host = "smtp.gmail.com"
        port = 465
        username = "test@test.com"
        password = "password"
        props = ["mail.smtp.auth":"true",
                "mail.smtp.socketFactory.port":"465",
                "mail.smtp.socketFactory.class":"javax.net.ssl.SSLSocketFactory",
                "mail.smtp.socketFactory.fallback":"false"]

    }
}

asynchronous.mail.default.attempt.interval = 300000l       // Five minutes
asynchronous.mail.default.max.attempts.count = 1
asynchronous.mail.send.repeat.interval = 60000l           // One minute
asynchronous.mail.expired.collector.repeat.interval = 607000l
asynchronous.mail.messages.at.once = 100
asynchronous.mail.send.immediately = true
asynchronous.mail.override = false
asynchronous.mail.clear.after.sent = false
asynchronous.mail.disable = false
asynchronous.mail.useFlushOnSave = true
asynchronous.mail.persistence.provider = 'hibernate4'      // Possible values are 'hibernate', 'hibernate4', 'mongodb'
asynchronous.mail.gparsPoolSize = 1
asynchronous.mail.newSessionOnImmediateSend = false

每当它成功发送电子邮件时,我都会看到这些日志:

2015-06-14 12:04:11,107 [ForkJoinPool-4071-worker-1] DEBUG asyncmail.AsynchronousMailProcessService  - Open new session.
2015-06-14 12:04:17,101 [ForkJoinPool-4071-worker-1] DEBUG asyncmail.AsynchronousMailProcessService  - Flush the session.
2015-06-14 12:04:17,101 [ForkJoinPool-4071-worker-1] DEBUG asyncmail.AsynchronousMailProcessService  - Destroy the session.
2015-06-14 12:04:17,101 [ForkJoinPool-4071-worker-1] DEBUG asyncmail.AsynchronousMailProcessService  - Open new session.
2015-06-14 12:04:23,125 [ForkJoinPool-4071-worker-1] DEBUG asyncmail.AsynchronousMailProcessService  - Flush the session.
2015-06-14 12:04:23,125 [ForkJoinPool-4071-worker-1] DEBUG asyncmail.AsynchronousMailProcessService  - Destroy the session.

但是,在某些情况下,它不会发送电子邮件,并且日志中没有打开/刷新/销毁会话。

当我查看数据库中的 async_mail_mess 表时,我可以看到那里的电子邮件条目具有 ERROR 状态。

我不确定是什么导致了此间歇性错误,并且无法从日志中看到任何堆栈跟踪。我应该增加最大尝试次数吗?如何捕捉这些错误?

【问题讨论】:

    标签: email session grails asynchronous quartz-scheduler


    【解决方案1】:

    插件在发送消息之前将消息状态更改为错误,之后将状态更改为已发送。在系统崩溃的情况下,需要防止双重发送。您似乎看到了正在发送的消息。

    【讨论】:

      猜你喜欢
      • 2010-10-03
      • 2016-03-16
      • 1970-01-01
      • 2016-09-17
      • 2016-09-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-02
      相关资源
      最近更新 更多