fixes the cases when the pop3 email server would not respond for a while
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portal/social-mail-servlet@146891 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
32376bcdb8
commit
41dee760bd
2
pom.xml
2
pom.xml
|
@ -11,7 +11,7 @@
|
||||||
<groupId>org.gcube.portal</groupId>
|
<groupId>org.gcube.portal</groupId>
|
||||||
<artifactId>social-mail-servlet</artifactId>
|
<artifactId>social-mail-servlet</artifactId>
|
||||||
<packaging>war</packaging>
|
<packaging>war</packaging>
|
||||||
<version>2.1.1-SNAPSHOT</version>
|
<version>2.2.0-SNAPSHOT</version>
|
||||||
|
|
||||||
<name>social-mail-servlet Webapp</name>
|
<name>social-mail-servlet Webapp</name>
|
||||||
<description>This component read periodically email replies from user wanting to reply to a post via email</description>
|
<description>This component read periodically email replies from user wanting to reply to a post via email</description>
|
||||||
|
|
|
@ -83,38 +83,7 @@ public class PortalSchedulerService extends HttpServlet {
|
||||||
_log.warn("Could not read popAccount data portal name", e);
|
_log.warn("Could not read popAccount data portal name", e);
|
||||||
}
|
}
|
||||||
_log.info("EmailParser stared for " + portalName + ", pollingInterval (in minutes)=" + pollingInterval);
|
_log.info("EmailParser stared for " + portalName + ", pollingInterval (in minutes)=" + pollingInterval);
|
||||||
|
|
||||||
boolean keepPolling = true;
|
|
||||||
while (keepPolling) {
|
|
||||||
try {
|
|
||||||
int newPolling = getPollingInterval();
|
|
||||||
if (newPolling <= 0) {
|
|
||||||
pop3Scheduler.shutdown();
|
|
||||||
_log.info("EmailParser stopped for " + popAccount.getPortalName() + ", found value less than 1 in gcube-data.properties file under $CATALINA_HOME/conf");
|
|
||||||
keepPolling = false;
|
|
||||||
}
|
|
||||||
else if (newPolling != pollingInterval) {
|
|
||||||
pollingInterval = newPolling;
|
|
||||||
pop3Scheduler.shutdown();
|
|
||||||
_log.debug("Current thread EmailParser stopped, starting new one with different polling rate ... ->" + pollingInterval);
|
|
||||||
pop3Scheduler = Executors.newScheduledThreadPool(1);
|
|
||||||
pop3Scheduler.scheduleAtFixedRate(new PeriodicTask(store, popAccount, request), 0, pollingInterval, TimeUnit.MINUTES);
|
|
||||||
_log.debug("EmailParser restarts in " + pollingInterval + " minutes, to change this polling delay edit gcube-data.properties file under $CATALINA_HOME/conf");
|
|
||||||
}
|
|
||||||
Thread.sleep(pollingInterval * 1000 * 60);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
toReturn = "<DIV>Check Notification Email Started ... </DIV>";
|
toReturn = "<DIV>Check Notification Email Started ... </DIV>";
|
||||||
|
|
||||||
// Thread likesThread = new Thread(new PeriodicTask(store, popAccount, request));
|
|
||||||
// likesThread.start();
|
|
||||||
|
|
||||||
response.setContentType("text/html");
|
response.setContentType("text/html");
|
||||||
response.getWriter().write(toReturn);
|
response.getWriter().write(toReturn);
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ import com.sun.mail.util.MailSSLSocketFactory;
|
||||||
public class PeriodicTask implements Runnable {
|
public class PeriodicTask implements Runnable {
|
||||||
private static final Log _log = LogFactoryUtil.getLog(PeriodicTask.class);
|
private static final Log _log = LogFactoryUtil.getLog(PeriodicTask.class);
|
||||||
private static final String APP_ID_NEWSFEED = "org.gcube.portlets.user.newsfeed.server.NewsServiceImpl";
|
private static final String APP_ID_NEWSFEED = "org.gcube.portlets.user.newsfeed.server.NewsServiceImpl";
|
||||||
|
|
||||||
private DatabookStore socialStore;
|
private DatabookStore socialStore;
|
||||||
private EmailPopAccount popAccount;
|
private EmailPopAccount popAccount;
|
||||||
private SocialNetworkingSite site;
|
private SocialNetworkingSite site;
|
||||||
|
@ -93,11 +93,16 @@ public class PeriodicTask implements Runnable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
_log.debug("PeriodicTask starting for portal/site having name: " + popAccount.getPortalName());
|
try {
|
||||||
check(popAccount.getPortalName(), popAccount.getPop3Server(), popAccount.getPop3user(), popAccount.getPop3password());
|
_log.debug("PeriodicTask starting for portal/site having name: " + popAccount.getPortalName());
|
||||||
|
check(popAccount.getPortalName(), popAccount.getPop3Server(), popAccount.getPop3user(), popAccount.getPop3password());
|
||||||
|
} catch (Exception e) {
|
||||||
|
_log.error("Exception during check email account, exiting ans stopping thread... ");
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return a fake session usuful for Notifications
|
* @return a fake session usuful for Notifications
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue