![]() |
|
|
|
|
Issue Type:
|
Bug
|
|
Affects Versions:
|
2.3.1 |
|
Assignee:
|
Aleksandr Pchelintcev
|
|
Components:
|
rss_generator |
|
Created:
|
10/Dec/14 2:02 PM
|
|
Description:
|
When the webapplication is shut down during RSS aggregator updates, the Thread pool of FastRSSFeedFetcher is not shut down properly and prevents the application from being shut down properly.
To fix this, Namics created a method in the ModuleLifecycle to fix this.
private void shutdownRssFeedFetcher() {
RSSFeedFetcher fetcher = Components.getComponent(RSSAggregator.class).getFetcher();
if (fetcher instanceof FastRSSFeedFetcher) {
FastRSSFeedFetcher fastFetcher = (FastRSSFeedFetcher) fetcher;
try {
Field executorServiceField = FastRSSFeedFetcher.class.getDeclaredField("executorService");
executorServiceField.setAccessible(true);
Object executorServiceObject = executorServiceField.get(fastFetcher);
if (executorServiceObject instanceof ExecutorService) {
ExecutorService executorService = (ExecutorService) executorServiceObject;
log.info("Shutting down feed fetcher executor service: " + executorService);
List<Runnable> terminated = executorService.shutdownNow();
log.info("Cancelled {} Runnable instances.", terminated.size());
log.info("Terminating feed fetcher executor service: " + executorService);
executorService.awaitTermination(5, TimeUnit.MINUTES);
}
} catch (Throwable e) {
log.error("Could not shutdown RSS Feed Fetcher", e);
}
}
}
Of course, it would be nice if the RSSFeedFetcher interface had a stop() method, and the RSSAggregator Module itself would stop it's fetcher.
To do this, I suggest a method like this:
public void shutdown() {
List<Runnable> runnables = executor.shutdownNow();
log.info("Canceling {} RSS Update Tasks because of shutdown...", runnables.size());
try {
if (executor.awaitTermination(5, TimeUnit.MINUTES)) {
log.info("Termination successful.");
} else {
log.error("Termination timed out.");
}
} catch (InterruptedException e) {
log.error("Termination error.", e);
}
}
|
|
Project:
|
Magnolia RSS Aggregator Module
|
|
Labels:
|
support
|
|
Priority:
|
Major
|
|
Reporter:
|
Lars Fischer
|
|
|
|
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
|
----------------------------------------------------------------
For list details, see: http://www.magnolia-cms.com/community/mailing-lists.html
Alternatively, use our forums: http://forum.magnolia-cms.com/
To unsubscribe, E-mail to: <
[email protected]>
----------------------------------------------------------------