Email 带有DatabaseMessageSource的Grails异步邮件插件

Email 带有DatabaseMessageSource的Grails异步邮件插件,email,grails,asynchronous,localization,Email,Grails,Asynchronous,Localization,在我的Grails应用程序中,需要允许在每个“组织”的基础上向用户显示不同的文本,但如果没有为组织定义覆盖文本,则需要返回到从messages.properties读取文本 我正在使用一种类似于详细说明的方法,这种方法在http请求范围内运行良好,但是我现在还需要在每个组织的基础上定义电子邮件内容,这有点问题,因为电子邮件是异步发送的(使用异步邮件插件)。我当前的resolveCode()实现如下所示: public MessageFormat resolveCode(String code,

在我的Grails应用程序中,需要允许在每个“组织”的基础上向用户显示不同的文本,但如果没有为组织定义覆盖文本,则需要返回到从messages.properties读取文本

我正在使用一种类似于详细说明的方法,这种方法在http请求范围内运行良好,但是我现在还需要在每个组织的基础上定义电子邮件内容,这有点问题,因为电子邮件是异步发送的(使用异步邮件插件)。我当前的
resolveCode()
实现如下所示:

public MessageFormat resolveCode(String code, Locale locale) {
    Message msg = null
    try {
        Organisation currentOrganisation = currentOrganisationSessionProxy.currentSessionOrganisation
        msg = Message.findByCodeAndLocaleAndOrganisation(code, locale, currentOrganisation)
    } catch (Exception e) { 
        //handle exception
    }

    def format

    if (msg) {
        format = new MessageFormat(msg.text, msg.locale)
    } else {
        format = messageBundleMessageSource.resolveCode(code, locale)
    }

    return format
}
我稍微修改了DatabaseMessageSource实现,因为我需要使用会话范围的代理解析当前的“会话”组织


有人能推荐一种异步发送本地化的、特定于组织的电子邮件的好方法吗?我想我需要将组织id与电子邮件一起保存,然后在我的
数据库messagesource
中检索它。非常感谢您的帮助。

事实证明,这比我想象的要简单。我不需要修改异步邮件插件,但我确实需要覆盖
ValidationTagLib
g:message
实现,以便传入
organizationid
。我还需要提供
AbstractMessageSource.getMessage
方法的替代实现,这些方法也采用
organizationid
参数