From 46a42c22d8e1bb953bf931c937f32bbddd665701 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Mon, 8 Aug 2011 01:13:13 -0400 Subject: [PATCH] Purging the request queue on context destruction to avoid lingering queued tasks --- .../jclouds/demo/tweetstore/config/SpringServletConfig.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/demos/tweetstore/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/SpringServletConfig.java b/demos/tweetstore/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/SpringServletConfig.java index 9e04dbde9e..50c5805065 100644 --- a/demos/tweetstore/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/SpringServletConfig.java +++ b/demos/tweetstore/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/SpringServletConfig.java @@ -87,6 +87,7 @@ public class SpringServletConfig extends LoggingConfig implements ServletConfigA private Map providerTypeToBlobStoreMap; private Twitter twitterClient; private String container; + private Queue queue; @PostConstruct public void initialize() throws IOException { @@ -119,7 +120,7 @@ public class SpringServletConfig extends LoggingConfig implements ServletConfigA } // 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 for (String name : providerTypeToBlobStoreMap.keySet()) { queue.add(withUrl("/store/do").header("context", name).method(Method.GET)); @@ -210,6 +211,9 @@ public class SpringServletConfig extends LoggingConfig implements ServletConfigA context.close(); } logger.trace("Contexts closed."); + logger.trace("About to purge request queue."); + queue.purge(); + logger.trace("Request queue purged."); } /*