branch develop updated (fb934a3 -> b3c86e1)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository pollen. See https://gitlab.nuiton.org/chorem/pollen.git from fb934a3 fix author new b3c86e1 tentative de correction des jobs de rappels de fin de sondage The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit b3c86e112b0a77fcc1e6312c61ba7c5157d388da Author: Kevin Morin <morin@codelutin.com> Date: Tue May 30 16:47:00 2017 +0200 tentative de correction des jobs de rappels de fin de sondage Summary of changes: .../src/main/resources/pollen-rest-api.properties | 3 - pollen-services/src/main/config/PollenServices.ini | 2 +- .../services/job/SendPollEndReminderJob.java | 65 +++++++++++++--------- 3 files changed, 39 insertions(+), 31 deletions(-) -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository pollen. See https://gitlab.nuiton.org/chorem/pollen.git commit b3c86e112b0a77fcc1e6312c61ba7c5157d388da Author: Kevin Morin <morin@codelutin.com> Date: Tue May 30 16:47:00 2017 +0200 tentative de correction des jobs de rappels de fin de sondage --- .../src/main/resources/pollen-rest-api.properties | 3 - pollen-services/src/main/config/PollenServices.ini | 2 +- .../services/job/SendPollEndReminderJob.java | 65 +++++++++++++--------- 3 files changed, 39 insertions(+), 31 deletions(-) diff --git a/pollen-rest-api/src/main/resources/pollen-rest-api.properties b/pollen-rest-api/src/main/resources/pollen-rest-api.properties index 67d3c3c..66f7e5d 100644 --- a/pollen-rest-api/src/main/resources/pollen-rest-api.properties +++ b/pollen-rest-api/src/main/resources/pollen-rest-api.properties @@ -29,6 +29,3 @@ hibernate.connection.provider_class=org.hibernate.hikaricp.internal.HikariCPConn hibernate.hikari.minimumIdle=2 hibernate.hikari.maximumPoolSize=20 hibernate.hikari.autoCommit=false - -pollen.sendVoteSummariesCronSchedule=0 0 0 * * ? -pollen.sendEndPollRemindersCronSchedule=0 0/5 * * * ? \ No newline at end of file diff --git a/pollen-services/src/main/config/PollenServices.ini b/pollen-services/src/main/config/PollenServices.ini index 79de3ed..34fa493 100644 --- a/pollen-services/src/main/config/PollenServices.ini +++ b/pollen-services/src/main/config/PollenServices.ini @@ -147,7 +147,7 @@ final = true description = pollen.configuration.sendEndPollRemindersCronSchedule key = pollen.sendEndPollRemindersCronSchedule type = string -default = "0 0/5 * * * ?" +defaultValue = "0 0/1 * * * ?" [option resourceMaxSize] description = pollen.configuration.resource.maxSize diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/job/SendPollEndReminderJob.java b/pollen-services/src/main/java/org/chorem/pollen/services/job/SendPollEndReminderJob.java index 6ebfab1..d40be9c 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/job/SendPollEndReminderJob.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/job/SendPollEndReminderJob.java @@ -8,6 +8,7 @@ import org.chorem.pollen.services.PollenApplicationContext; import org.chorem.pollen.services.PollenServiceContext; import org.chorem.pollen.services.service.NotificationService; import org.chorem.pollen.services.service.PollService; +import org.quartz.DisallowConcurrentExecution; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; @@ -17,50 +18,60 @@ import java.util.Locale; /** * @author Kevin Morin (Code Lutin) */ +@DisallowConcurrentExecution public class SendPollEndReminderJob extends AbstractPollenJob { /** Logger. */ private static final Log log = LogFactory.getLog(SendPollEndReminderJob.class); + protected PollenApplicationContext applicationContext; + @Override public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { if (log.isDebugEnabled()) { log.debug("Start job to send reminder emails to the poll owners"); } - PollenApplicationContext applicationContext = getApplicationContext(jobExecutionContext); - PollenTopiaPersistenceContext persistenceContext = applicationContext.newPersistenceContext(); - PollenServiceContext serviceContext = applicationContext.newServiceContext(persistenceContext, Locale.getDefault()); + applicationContext = getApplicationContext(jobExecutionContext); + PollenTopiaPersistenceContext persistenceContext = null; + + try { + persistenceContext = applicationContext.newPersistenceContext(); + PollenServiceContext serviceContext = applicationContext.newServiceContext(persistenceContext, Locale.getDefault()); - PollService pollService = serviceContext.newService(PollService.class); - Collection<Poll> pollsWithVoteReminderNeeded = pollService.getPollsWithReminderNeeded(); + PollService pollService = serviceContext.newService(PollService.class); + Collection<Poll> pollsWithVoteReminderNeeded = pollService.getPollsWithReminderNeeded(); - for (Poll poll : pollsWithVoteReminderNeeded) { - try { - Locale locale; - if (poll.getNotificationLocale() != null) { - locale = Locale.forLanguageTag(poll.getNotificationLocale()); - } else { - locale = Locale.getDefault(); + for (Poll poll : pollsWithVoteReminderNeeded) { + if (log.isDebugEnabled()) { + log.debug("Send reminder for poll " + poll.getTitle()); } - PollenServiceContext localizedServiceContext = applicationContext.newServiceContext(persistenceContext, locale); - localizedServiceContext.newService(NotificationService.class).sendPollEndReminder(poll); + try { + Locale locale; + if (poll.getNotificationLocale() != null) { + locale = Locale.forLanguageTag(poll.getNotificationLocale()); + } else { + locale = Locale.getDefault(); + } + PollenServiceContext localizedServiceContext = applicationContext.newServiceContext(persistenceContext, locale); + localizedServiceContext.newService(NotificationService.class).sendPollEndReminder(poll); - // save last notification date - poll.setPollEndReminderSent(true); - pollService.commit(); + // save last notification date + poll.setPollEndReminderSent(true); + pollService.commit(); - } catch (Exception e) { - if (log.isErrorEnabled()) { - log.error("Error while sending end reminder for poll " + poll.getTopiaId(), e); + } catch (Exception e) { + if (log.isErrorEnabled()) { + log.error("Error while sending end reminder for poll " + poll.getTopiaId(), e); + } } } - } - - if (!persistenceContext.isClosed()) { - persistenceContext.close(); - } else { - if (log.isDebugEnabled()) { - log.debug("persistence context already closed..."); + } finally { + if (persistenceContext != null && !persistenceContext.isClosed()) { + persistenceContext.close(); + } else { + if (log.isDebugEnabled()) { + log.debug("persistence context already closed..."); + } } } } -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm