Purging the request queue on context destruction to avoid lingering queued tasks

This commit is contained in:
Andrew Phillips 2011-08-08 01:13:13 -04:00
parent 57c0f19b00
commit 46a42c22d8
1 changed files with 5 additions and 1 deletions

View File

@ -87,6 +87,7 @@ public class SpringServletConfig extends LoggingConfig implements ServletConfigA
private Map<String, BlobStoreContext> providerTypeToBlobStoreMap; private Map<String, BlobStoreContext> providerTypeToBlobStoreMap;
private Twitter twitterClient; private Twitter twitterClient;
private String container; private String container;
private Queue queue;
@PostConstruct @PostConstruct
public void initialize() throws IOException { public void initialize() throws IOException {
@ -119,7 +120,7 @@ public class SpringServletConfig extends LoggingConfig implements ServletConfigA
} }
// get a queue for submitting store tweet requests // get a queue for submitting store tweet requests
Queue queue = QueueFactory.getQueue("twitter"); queue = QueueFactory.getQueue("twitter");
// submit a job to store tweets for each configured blobstore // submit a job to store tweets for each configured blobstore
for (String name : providerTypeToBlobStoreMap.keySet()) { for (String name : providerTypeToBlobStoreMap.keySet()) {
queue.add(withUrl("/store/do").header("context", name).method(Method.GET)); queue.add(withUrl("/store/do").header("context", name).method(Method.GET));
@ -210,6 +211,9 @@ public class SpringServletConfig extends LoggingConfig implements ServletConfigA
context.close(); context.close();
} }
logger.trace("Contexts closed."); logger.trace("Contexts closed.");
logger.trace("About to purge request queue.");
queue.purge();
logger.trace("Request queue purged.");
} }
/* /*