Skip to content
This repository was archived by the owner on Jan 18, 2022. It is now read-only.

Grails 4.0.x #97

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ database with Grails domain classes and sends them by a scheduled Quartz job. Ma
the `sendAsynchronousMail` (or `sendMail`) method returning instantly, is not waiting for the mail to be actually sent. If
the SMTP server isn't available, or other errors occur, the plugin can be set to retry later.

The plugin depends on the [quartz](https://grails.org/plugins.html#plugin/quartz) and the [mail](https://grails.org/plugins.html#plugin/mail) plugins. You also need a persistence provider plugin, [hibernate4](https://grails.org/plugins.html#plugin/hibernate4) and [mongodb](https://grails.org/plugins.html#plugin/mongodb) are supported.
The plugin depends on the [quartz](https://grails.org/plugins.html#plugin/quartz) and the [mail](https://grails.org/plugins.html#plugin/mail) plugins. You also need a persistence provider plugin, [hibernate5](https://plugins.grails.org/plugin/grails/hibernate5) and [mongodb](https://plugins.grails.org/plugin/grails/mongodb) are supported.

Links
-----

* The plugin page: <https://grails.org/plugins.html#plugin/asynchronous-mail>
* The plugin page: <https://plugins.grails.org/plugin/kefirsf/asynchronous-mail>
* The VCS repository (GitHub): <https://github.com/kefirfromperm/grails-asynchronous-mail>
* The issue tracker (GitHub): <https://github.com/kefirfromperm/grails-asynchronous-mail/issues>
* The repository package (BinTray): <https://bintray.com/kefirsf/plugins/asynchronous-mail/>
Expand All @@ -25,14 +25,17 @@ Links
Installation
------------

To install just add the plugin to the plugins block of `build.gradle`. For Grails 3.3.x
To install just add the plugin to the plugins block of `build.gradle`. For Grails 4.0.x
```groovy
compile "org.grails.plugins:asynchronous-mail:3.0.0"
```

For Grails 3.3.x
```groovy
compile "org.grails.plugins:asynchronous-mail:2.0.2"
```

For Grails 3.2.11 and earlier

```groovy
compile "org.grails.plugins:asynchronous-mail:2.0.2-3.2.x"
```
Expand All @@ -52,7 +55,7 @@ asynchronous.mail.send.immediately=true
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.persistence.provider='hibernate5' // Possible values are 'hibernate', 'hibernate4', 'hibernate5', 'mongodb'
asynchronous.mail.newSessionOnImmediateSend=false
asynchronous.mail.taskPoolSize=1
```
Expand All @@ -70,16 +73,16 @@ If you want to change this options just add options which you want to change to
|`asynchronous.mail.clear.after.sent`|`false`|If `true` then all messages will be deleted after sent. If `attachments` then attachments of all messages will be deleted.|
|`asynchronous.mail.disable`|`false`|If true then jobs aren't started.|
|`asynchronous.mail.useFlushOnSave`|`true`|By default the plugin flushes all changes to the DB on every step of the sending process for prevent resending but it makes overhead. So you can set this property to `false` and it will have better performance but will not have guarantee of prevention of resending.|
|`asynchronous.mail.persistence.provider`|`hibernate4`|The persistence provider. Possible values are `hibernate`, `hibernate3`, `hibernate4`, `hibernate5`, `mongodb`.|
|`asynchronous.mail.persistence.provider`|`hibernate5`|The persistence provider. Possible values are `hibernate`, `hibernate3`, `hibernate4`, `hibernate5`, `mongodb`.|
|`asynchronous.mail.newSessionOnImmediateSend`|`false`|If `true` the new DB session will be created for storing a message into DB. It's needed if you want to send an email in case of error when all changes in DB are rolled back.|
|`asynchronous.mail.taskPoolSize`|`1`|Max count of parallel tasks for sending messages concurrently.|

Configure the [mail](https://grails.org/plugins.html#plugin/mail) plugin. The Asynchronous Mail plugin uses the [mail](https://grails.org/plugins.html#plugin/mail) plugin for sending messages to the SMTP server.
Configure the [mail](https://plugins.grails.org/plugin/grails/mail) plugin. The Asynchronous Mail plugin uses the [mail](https://plugins.grails.org/plugin/grails/mail) plugin for sending messages to the SMTP server.

Usage
-----

If you already used the [mail](https://grails.org/plugins.html#plugin/mail) plugin, you have to import class `AsynchronousMailService` to your class.
If you already used the [mail](https://plugins.grails.org/plugin/grails/mail) plugin, you have to import class `AsynchronousMailService` to your class.

```groovy
import grails.plugin.asyncmail.AsynchronousMailService
Expand Down
86 changes: 60 additions & 26 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,65 +1,94 @@
buildscript {
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
}
dependencies {
classpath "org.grails:grails-gradle-plugin:$grailsVersion"
classpath "com.bertramlabs.plugins:asset-pipeline-gradle:2.14.2"
classpath "com.bertramlabs.plugins:asset-pipeline-gradle:3.0.10"
classpath "org.grails.plugins:hibernate5:7.0.4"
}
}

version "2.0.2"
version "3.0.0"
group "org.grails.plugins"

apply plugin:"eclipse"
apply plugin: 'idea'
apply plugin:"org.grails.grails-plugin"
apply plugin:"org.grails.grails-plugin-publish"
apply plugin:"org.grails.grails-gsp"
apply plugin:"asset-pipeline"

ext {
grailsVersion = project.grailsVersion
gradleWrapperVersion = project.gradleWrapperVersion
}
apply plugin:"org.grails.grails-gsp"

repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
}

configurations {
developmentOnly
runtimeClasspath {
extendsFrom developmentOnly
}
}

dependencies {
developmentOnly("org.springframework.boot:spring-boot-devtools")
compile "org.springframework.boot:spring-boot-starter-logging"
compile "org.springframework.boot:spring-boot-autoconfigure"
compile "org.grails:grails-core"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile "org.springframework.boot:spring-boot-starter-tomcat"
compile "org.grails:grails-dependencies"
compile "org.grails:grails-web-boot"
compile "org.grails:grails-logging"
compile "org.grails:grails-plugin-rest"
compile "org.grails:grails-plugin-databinding"
compile "org.grails:grails-plugin-i18n"
compile "org.grails:grails-plugin-services"
compile "org.grails:grails-plugin-url-mappings"
compile "org.grails:grails-plugin-interceptors"
compile "org.grails.plugins:cache"
compile "org.grails.plugins:async"
compile "org.grails.plugins:scaffolding"
compile "org.grails.plugins:hibernate5"
compile "org.hibernate:hibernate-core:5.4.18.Final"
compile "org.grails.plugins:mongodb"
compile "org.grails.plugins:gsp"
compile "org.grails.plugins:mail:3.0.0"
// This is needed for the quartz-plugin on grails 4.0.x, https://github.com/grails-plugins/grails-quartz/issues/107#issuecomment-575951471
compile("org.quartz-scheduler:quartz:2.2.3") {
exclude group: 'slf4j-api', module: 'c3p0'
}
compile ('org.grails.plugins:quartz:2.0.13')
compileOnly "io.micronaut:micronaut-inject-groovy"
console "org.grails:grails-console"
profile "org.grails.profiles:web-plugin"
provided "org.grails:grails-plugin-services"
provided "org.grails:grails-plugin-domain-class"

runtime "org.apache.tomcat:tomcat-jdbc"
runtime "com.bertramlabs.plugins:asset-pipeline-grails:3.0.10"
testCompile "io.micronaut:micronaut-inject-groovy"
testCompile "org.grails:grails-gorm-testing-support"
testCompile "net.bytebuddy:byte-buddy:1.7.9"
testCompile "org.grails.plugins:hibernate5"
testCompile "com.h2database:h2:1.4.196"

compile "org.grails.plugins:mail:2.0.0"
compile "org.grails.plugins:quartz:2.0.13"
testCompile "org.mockito:mockito-core"
testCompile "org.grails:grails-web-testing-support"
}

assets {
packagePlugin = true
bootRun {
ignoreExitValue true
jvmArgs(
'-Dspring.output.ansi.enabled=always',
'-noverify',
'-XX:TieredStopAtLevel=1',
'-Xmx1024m')
sourceResources sourceSets.main
String springProfilesActive = 'spring.profiles.active'
systemProperty springProfilesActive, System.getProperty(springProfilesActive)
}

task wrapper(type: Wrapper) {
gradleVersion = gradleWrapperVersion
}

tasks.withType(GroovyCompile) {
configure(groovyOptions) {
forkOptions.jvmArgs = ['-Xmx1024m']
}
}
// enable if you wish to package this plugin as a standalone application
bootJar.enabled = false
grailsPublish {
userOrg = 'kefirsf'
license {
Expand All @@ -83,6 +112,11 @@ grailsPublish {
'micke-a':"Mikael Andersson",
pgdoval:"Pablo González Doval",
Uniqen:"Magnus Dalin",
demon101:"Demon"
demon101:"Demon",
matrei:"Mattias Reichel"
]
}

assets {
packagePlugin = true
}
8 changes: 5 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
grailsVersion=3.3.2
gormVersion=6.1.8.RELEASE
gradleWrapperVersion=3.5.1
grailsVersion=4.0.6
gormVersion=7.0.8.RELEASE
org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.jvmargs=-Dfile.encoding=UTF-8 -Xmx1024M
3 changes: 1 addition & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Mon Jan 15 10:44:43 YEKT 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-bin.zip
36 changes: 0 additions & 36 deletions grails-app/conf/application.groovy

This file was deleted.

112 changes: 112 additions & 0 deletions grails-app/conf/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
---
grails:
profile: web-plugin
codegen:
defaultPackage: grails.plugin.asyncmail
gorm:
reactor:
# Whether to translate GORM events into Reactor events
# Disabled by default for performance reasons
events: false
info:
app:
name: '@info.app.name@'
version: '@info.app.version@'
grailsVersion: '@info.app.grailsVersion@'
spring:
jmx:
unique-names: true
main:
banner-mode: "off"
groovy:
template:
check-template-location: false
devtools:
restart:
additional-exclude:
- '*.gsp'
- '**/*.gsp'
- '*.gson'
- '**/*.gson'
- 'logback.groovy'
- '*.properties'
management:
endpoints:
enabled-by-default: false

---
grails:
mime:
disable:
accept:
header:
userAgents:
- Gecko
- WebKit
- Presto
- Trident
types:
all: '*/*'
atom: application/atom+xml
css: text/css
csv: text/csv
form: application/x-www-form-urlencoded
html:
- text/html
- application/xhtml+xml
js: text/javascript
json:
- application/json
- text/json
multipartForm: multipart/form-data
pdf: application/pdf
rss: application/rss+xml
text: text/plain
hal:
- application/hal+json
- application/hal+xml
xml:
- text/xml
- application/xml
urlmapping:
cache:
maxsize: 1000
controllers:
defaultScope: singleton
converters:
encoding: UTF-8
views:
default:
codec: html
gsp:
encoding: UTF-8
htmlcodec: xml
codecs:
expression: html
scriptlet: html
taglib: none
staticparts: none
management:
endpoints:
jmx:
unique-names: true

---

environments:
test:
quartz:
jdbcStore: false
hibernate:
cache:
queries: false
use_second_level_cache: false
use_query_cache: false
dataSource:
pooled: true
jmxExport: true
driverClassName: org.h2.Driver
username: sa
password: ''
dbCreate: create-drop
url: jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
2 changes: 1 addition & 1 deletion grails-app/conf/plugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ asynchronous.mail.send.immediately=true
asynchronous.mail.clear.after.sent=false // true, false, 'attachments'
asynchronous.mail.disable=false
asynchronous.mail.useFlushOnSave=true
asynchronous.mail.persistence.provider='hibernate4' // Possible values are 'hibernate', 'hibernate4', 'mongodb'
asynchronous.mail.persistence.provider='hibernate5' // Possible values are 'hibernate', 'hibernate4', 'hibernate5', 'mongodb'
asynchronous.mail.newSessionOnImmediateSend=false
asynchronous.mail.taskPoolSize=1
4 changes: 3 additions & 1 deletion grails-app/init/grails/plugin/asyncmail/Application.groovy
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package grails.plugin.asyncmail

import grails.boot.GrailsApp
import grails.boot.*
import grails.boot.config.GrailsAutoConfiguration
import grails.plugins.metadata.*

@PluginSource
class Application extends GrailsAutoConfiguration {
static void main(String[] args) {
GrailsApp.run(Application, args)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package grails.plugin.asyncmail

import grails.gorm.transactions.Transactional
import grails.plugin.asyncmail.enums.MessageStatus
import groovy.transform.CompileStatic
import groovy.util.logging.Slf4j

@Slf4j
@Transactional
class AsynchronousMailPersistenceService {

AsynchronousMailConfigService asynchronousMailConfigService
Expand Down
Loading