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

Branch v1.2 #93

Open
wants to merge 70 commits into
base: 1.0.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
07d43d0
Upgrade Grails version to 2.3.1
Nov 7, 2013
5e2d70b
README code highlight
stokito Dec 7, 2013
4b76425
Merge pull request #24 from stokito/patch-1
Dec 7, 2013
8dce557
Update README.md
Dec 7, 2013
2fc3c51
Grails upgraded to 2.3.5
May 19, 2014
598f554
Added support for mongodb.
May 19, 2014
df57a8d
Merge pull request #1 from causecode/mongo-support
visheshd Jun 4, 2014
5791f18
Added config to use mongo instead of hibernate.
Jun 5, 2014
ffb80cf
Cleanup.
Jun 5, 2014
1839c98
avoid session flush problems in AsynchronousMailService
aberbenni Jun 5, 2014
6753252
asynchronous.mail.newSessionOnImmediateSend config
aberbenni Jun 6, 2014
c5670e9
asynchronous.mail.newSessionOnImmediateSend default config
aberbenni Jun 6, 2014
bc4a54f
Released plugin version for fix with mongodb.
Jun 6, 2014
c6257a1
Merge pull request #30 from causecode/master
kefirfromperm Jun 8, 2014
2b8fc0e
Merge pull request #32 from aberbenni/master
kefirfromperm Jun 8, 2014
bd51a0d
Change Grails version to 2.3.9
Jun 8, 2014
ca19f65
New session when send message immediately.
Jun 8, 2014
0741af5
Add the hibernate dependency with the test scope.
Jun 8, 2014
14c4d15
#31 Triggers on cluster
Jun 8, 2014
48c8178
#33 The new mail plugin version.
Jun 9, 2014
c4969db
Support Hibernate4
Jun 19, 2014
7d95add
MongoDB
Jun 20, 2014
354b4b7
Update the Quartz plugin version to 1.0.2.
Jun 20, 2014
9906bc2
Triggers
Jun 20, 2014
9013bb6
Hibernate plugin dependency for tests.
Jun 20, 2014
78dbb38
#34 A package parameter for the create controller script
Jul 5, 2014
fd74bfa
The property persistence.provider
Jul 5, 2014
39b9a19
Release candidate.
Jul 5, 2014
a512f39
GPASYNCHRONOUSMAIL-32 #31 Removing old triggers.
Jul 6, 2014
038df9b
Upgrade the GPars version to 1.2.1
Jul 6, 2014
6d80c57
Update README.md
kefirfromperm Jul 7, 2014
4c13a5a
Update an email in the readme
kefirfromperm Jul 7, 2014
7c7521b
Count of updated messages which marked as expired for MongoDB.
Jul 7, 2014
3364630
Merge remote-tracking branch 'origin/master'
Jul 7, 2014
6674ab7
Link at Ohloh
kefirfromperm Jul 8, 2014
5232c9c
Update README.md
kefirfromperm Jul 8, 2014
d941575
Update README.md
kefirfromperm Jul 8, 2014
907a324
Update README.md
kefirfromperm Jul 8, 2014
e43836a
Link at the sample application in readme.
Jul 8, 2014
91e02af
Version 1.1
Sep 10, 2014
8edbab5
Readme was updated.
Sep 10, 2014
b534805
#36 Compatibility with Oracle. https://forum.hibernate.org/viewtopic.…
Nov 3, 2014
1fafbba
Update plugins versions.
Nov 8, 2014
123f72b
Version 1.2-SNAPSHOT
Nov 8, 2014
ec32bd8
Clean AsynchronousMailMessage.
Nov 8, 2014
509f45d
README
Nov 8, 2014
b6b1b26
envelopeFrom
Nov 11, 2014
5047a36
GPASYNCHRONOUSMAIL-35 Catch all exception on mail sending.
Nov 11, 2014
ec378c0
Update the grails hibernate plugin version.
Nov 12, 2014
b661d6f
Upgrade the plugin version to 1.2-RC
Nov 12, 2014
bf40a74
cleanup readme
dpcasady Nov 13, 2014
e9db743
cleanup exceptions
dpcasady Nov 13, 2014
64edb36
cleanup comments
dpcasady Nov 13, 2014
bb34b6d
Merge pull request #37 from dpcasady/master
kefirfromperm Nov 13, 2014
5c1600f
Refactor CreateAsynchronousMailController script
dpcasady Nov 13, 2014
19b90b7
Update README.md
stokito Nov 13, 2014
fade22a
Merge pull request #39 from stokito/patch-2
kefirfromperm Nov 13, 2014
650c05e
Merge pull request #38 from dpcasady/master
kefirfromperm Nov 13, 2014
fc9657d
Using PagedResultList
Nov 13, 2014
9ceb90d
Variables in the controller template.
Nov 13, 2014
db65238
cleanup logging
dpcasady Nov 13, 2014
234a107
split long if statement conditions into predefined booleans
dpcasady Nov 13, 2014
2e46754
add convenience methods for checking message status
dpcasady Nov 13, 2014
2fa7e58
Merge pull request #40 from dpcasady/cleanup
kefirfromperm Nov 15, 2014
6376ec1
Rename exception variable.
Nov 16, 2014
de69fd8
Upgrade version to 1.2-RC2
Nov 16, 2014
5e22998
Add flushes in the controller template for the Hibernate4 plugin.
Nov 16, 2014
189f4f8
Update readme
Nov 17, 2014
7be3f05
Release 1.2
Nov 23, 2014
ed2f861
Add trace logs mo mail sending service
crc83 Nov 18, 2019
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
87 changes: 0 additions & 87 deletions .classpath

This file was deleted.

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

# Target
target/
target-eclipse/

# Unused web-app files
web-app/WEB-INF/
Expand All @@ -27,3 +28,5 @@ plugin.xml
# Unused grails files
grails-app/i18n/
grails-app/conf/UrlMappings.groovy
.classpath
.project
32 changes: 0 additions & 32 deletions .project

This file was deleted.

61 changes: 52 additions & 9 deletions AsynchronousMailGrailsPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@ import grails.plugin.asyncmail.AsynchronousMailJob
import grails.plugin.asyncmail.AsynchronousMailMessageBuilderFactory
import grails.plugin.asyncmail.ExpiredMessagesCollectorJob
import grails.plugin.mail.MailService
import grails.plugins.quartz.*
import grails.util.Environment
import org.codehaus.groovy.grails.commons.spring.GrailsApplicationContext
import org.quartz.Scheduler
import org.quartz.TriggerKey
import org.slf4j.Logger
import org.slf4j.LoggerFactory

class AsynchronousMailGrailsPlugin {
def version = "1.0"
def grailsVersion = "2.0.0 > *"
def loadAfter = ['mail', 'quartz', 'hibernate']
def version = "1.2"
def grailsVersion = "2.3.1 > *"
def loadAfter = ['mail', 'quartz', 'hibernate', 'hibernate4', 'mongodb']
def pluginExcludes = [
"grails-app/conf/DataSource.groovy",
"grails-app/i18n/**",
Expand All @@ -22,7 +27,7 @@ class AsynchronousMailGrailsPlugin {
]

def author = "Vitalii Samolovskikh aka Kefir"
def authorEmail = "kefir@perm.ru"
def authorEmail = "kefirfromperm@gmail.com"
def title = "Asynchronous Mail Plugin"
def description = 'The plugin realises asynchronous mail sending. ' +
'It stores messages in the DB and sends them asynchronously by the quartz job.'
Expand All @@ -32,6 +37,9 @@ class AsynchronousMailGrailsPlugin {
def issueManagement = [system: 'JIRA', url: 'http://jira.grails.org/browse/GPASYNCHRONOUSMAIL']
def scm = [url: 'https://github.com/kefirfromperm/grails-asynchronous-mail']

// The logger for the plugin class
private Logger log = LoggerFactory.getLogger('grails.plugin.asyncmail.AsynchronousMailJob')

def doWithSpring = {
loadAsyncMailConfig(application.config)

Expand All @@ -54,7 +62,7 @@ class AsynchronousMailGrailsPlugin {
configureSendMail(application, applicationContext)

// Starts jobs
startJobs(application)
startJobs(application, applicationContext)
}

def onChange = { event ->
Expand All @@ -63,13 +71,48 @@ class AsynchronousMailGrailsPlugin {
}

/**
* Start send job and messages collector
* Start the send job and the messages collector.
*
* If the plugin is used in cluster we have to remove old triggers.
*/
static startJobs(application) {
def startJobs(application, applicationContext) {
def asyncMailConfig = application.config.asynchronous.mail
if (!asyncMailConfig.disable) {
AsynchronousMailJob.schedule((Long) asyncMailConfig.send.repeat.interval)
ExpiredMessagesCollectorJob.schedule((Long) asyncMailConfig.expired.collector.repeat.interval)
JobManagerService jobManagerService = applicationContext.jobManagerService
Scheduler quartzScheduler = applicationContext.quartzScheduler

// Get our jobs
List<JobDescriptor> jobDescriptors = jobManagerService.getJobs("AsynchronousMail")

// Remove old triggers for the send job
log.debug("Removing old triggers for the AsynchronousMailJob")
JobDescriptor sjd = jobDescriptors.find { it.name == 'grails.plugin.asyncmail.AsynchronousMailJob' }
sjd?.triggerDescriptors?.each {TriggerDescriptor td ->
def triggerKey = new TriggerKey(td.name, td.group)
quartzScheduler.unscheduleJob(triggerKey)
log.debug("Removed the trigger ${triggerKey} for the AsynchronousMailJob")
}

// Schedule the send job
def sendInterval = (Long) asyncMailConfig.send.repeat.interval
log.debug("Scheduling the AsynchronousMailJob with repeat interval ${sendInterval}ms")
AsynchronousMailJob.schedule(sendInterval)
log.debug("Scheduled the AsynchronousMailJob with repeat interval ${sendInterval}ms")

// Remove old triggers for the collector job
log.debug("Removing old triggers for the ExpiredMessagesCollectorJob")
JobDescriptor cjd = jobDescriptors.find { it.name == 'grails.plugin.asyncmail.ExpiredMessagesCollectorJob' }
cjd?.triggerDescriptors?.each {TriggerDescriptor td ->
def triggerKey = new TriggerKey(td.name, td.group)
quartzScheduler.unscheduleJob(triggerKey)
log.debug("Removed the trigger ${triggerKey} for the ExpiredMessagesCollectorJob")
}

// Schedule the collector job
def collectInterval = (Long) asyncMailConfig.expired.collector.repeat.interval
log.debug("Scheduling the ExpiredMessagesCollectorJob with repeat interval ${collectInterval}ms")
ExpiredMessagesCollectorJob.schedule(collectInterval)
log.debug("Scheduled the ExpiredMessagesCollectorJob with repeat interval ${collectInterval}ms")
}
}

Expand Down
74 changes: 41 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,70 +1,78 @@
The Grails Asynchronous Mail plug-in
The Grails Asynchronous Mail plugin
====================================

Description
-----------

The Grails Asynchronous Mail is a plugin for asynchronous sending of email messages. It stores email messages in the DB
using Grails domain classes and sends them by a scheduled job. It allows to react to user's actions faster. If the SMTP
server isn't available in time then the plugin can sends message after, when the server will be available.
Grails Asynchronous Mail is a plugin for sending email messages asynchronously. It persists email messages to the database
with Grails domain classes and sends them by a scheduled Quartz job. Mail is sent on a different thread, with the
`sendAsynchronousMail` (or `sendMail`) method returning instantly, 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 [hibernate](http://www.grails.org/plugin/hibernate),
[quartz](http://www.grails.org/plugin/quartz) and [mail](http://www.grails.org/plugin/mail) plugins.
The plugin depends on the [quartz](http://www.grails.org/plugin/quartz) and [mail](http://www.grails.org/plugin/mail)
plugins. You also need a persistence provider plugin: [hibernate](http://www.grails.org/plugin/hibernate),
[hibernate4](http://www.grails.org/plugin/hibernate4) and [mongodb](http://www.grails.org/plugin/mongodb) are supported.

Links
-----

The plugin page: <http://grails.org/plugin/asynchronous-mail>
Repository (GitHub): <https://github.com/kefirfromperm/grails-asynchronous-mail>
Issue tracker (Jira): <http://jira.grails.org/browse/GPASYNCHRONOUSMAIL>
* The plugin main page: <http://grails.org/plugin/asynchronous-mail>
* The VCS repository (GitHub): <https://github.com/kefirfromperm/grails-asynchronous-mail>
* The issue tracker (Jira): <http://jira.grails.org/browse/GPASYNCHRONOUSMAIL>
* The page at OpenHUB: <https://www.openhub.net/p/grails-asynchronous-mail>

Installation
------------

For start to use the plugin just add a dependency in the `BuildConfig.groovy`.

compile ":asynchronous-mail:1.0-RC6"
To install, add the plugin to the plugins block of `BuildConfig.groovy`:
```groovy
compile ":asynchronous-mail:1.2"
```

Documentation
-------------

Full documentation is available on [the plugin page](http://grails.org/plugin/asynchronous-mail).
Full documentation is available at [the plugin page](http://grails.org/plugin/asynchronous-mail).

Also see the sample application at <https://github.com/kefirfromperm/grails-asynchronous-mail-sample>.

Contribution
------------

If you want to contribute the plugin just open a pull request to repository
If you want to contribute to the plugin, open a pull request to the repository
<https://github.com/kefirfromperm/grails-asynchronous-mail>.

Unit tests are very very sweet things. They help us find bugs, modify code without new bugs. It's very interesting to
Unit tests are very very sweet things. They help us find bugs, and modify code without adding new bugs. It's very interesting to
see how they work. I like to see how they work. What is the better than unit tests? More unit tests!
Unit tests are good!

And comments... Comments are good also. They are not better than unit tests, but they are good, definitely. If you known
Chinese or Arabic it is good. Seriously. It's awesome! But I don't known them. So write comments in English.
And comments... Comments are good also. They are not better than unit tests, but they are definitely good. If you known
Chinese or Arabic, that is good. Seriously. It's awesome! But I don't known them. So write comments in English.

Logging
-------

For enable full plugin log add following lines to the configuration (`/grails-app/conf/Config.grovy`).

log4j = {
// Enable the Asynchronous Mail plugin logging
trace 'grails.app.jobs.grails.plugin.asyncmail', 'grails.app.services.grails.plugin.asyncmail'

// Enable the Quartz plugin logging
debug 'grails.plugins.quartz'
}
To enable full logging for the plugin, add the following lines to `/grails-app/conf/Config.grovy`.
```groovy
log4j = {
...
// Enable Asynchronous Mail plugin logging
trace 'grails.app.jobs.grails.plugin.asyncmail',
'grails.app.services.grails.plugin.asyncmail',
'grails.plugin.asyncmail'

// Enable Quartz plugin logging
debug 'grails.plugins.quartz'
...
}
```

Issue tracking
--------------

You can report about bugs on the [JIRA](http://jira.grails.org/browse/GPASYNCHRONOUSMAIL) or
You can report bugs on [JIRA](http://jira.grails.org/browse/GPASYNCHRONOUSMAIL) or
[GitHub](https://github.com/kefirfromperm/grails-asynchronous-mail/issues?state=open).
You also can ask me by email [kefir@perm.ru](mailto:kefir@perm.ru).

Please, enable logs and attach it to your issue.
You also can ask me questions by email [kefirfromperm@gmail.com](mailto:kefirfromperm@gmail.com).
Please, enable logs and attach them to your issue.

Please, review this project on [Ohloh](https://www.ohloh.net/p/grails-asynchronous-mail).
Please, review this project at [OpenHUB](https://www.openhub.net/p/grails-asynchronous-mail).
9 changes: 5 additions & 4 deletions application.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#Grails Metadata file
#Sat Sep 28 14:29:26 YEKT 2013
app.grails.version=2.0.0
app.name=grails-asynchronous-mail
#Grails Metadata file
#Tue Nov 04 00:00:08 YEKT 2014
app.grails.version=2.3.11
app.name=grails-asynchronous-mail
app.servlet.version=2.5
11 changes: 5 additions & 6 deletions grails-app/conf/BuildConfig.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,20 @@ grails.project.dependency.resolution = {
}

dependencies {
compile "org.codehaus.gpars:gpars:1.0.0"
compile "org.codehaus.jsr166-mirror:jsr166y:1.7.0"
compile "org.codehaus.gpars:gpars:1.2.1"
}

plugins {
runtime(":hibernate:2.0.0") {
test(":hibernate:3.6.10.16") {
export = false
}

compile(':mail:1.0.1'){
compile(':mail:1.0.7'){
excludes 'spring-test'
}
compile ':quartz:1.0.1'
compile ':quartz:1.0.2'

build(':release:2.1.0', ':rest-client-builder:1.0.3') {
build(':release:3.0.1', ':rest-client-builder:2.0.3') {
export = false
}
}
Expand Down
2 changes: 2 additions & 0 deletions grails-app/conf/DefaultAsynchronousMailConfig.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ asynchronous.mail.override=false
asynchronous.mail.clear.after.sent=false
asynchronous.mail.disable=false
asynchronous.mail.useFlushOnSave=true
asynchronous.mail.persistence.provider='hibernate' // Possible values are 'hibernate', 'hibernate4', 'mongodb'
asynchronous.mail.gparsPoolSize=1
asynchronous.mail.newSessionOnImmediateSend=false
Loading