CAMEL-9827: Downgrade the embed mongodb as it does not work.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/d5d659eb Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/d5d659eb Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/d5d659eb Branch: refs/heads/master Commit: d5d659eb4c4ce897738644e1d41793330d50c0f4 Parents: 6a4b8ce Author: Claus Ibsen <davscl...@apache.org> Authored: Thu Apr 7 09:12:27 2016 +0200 Committer: Claus Ibsen <davscl...@apache.org> Committed: Thu Apr 7 09:39:40 2016 +0200 ---------------------------------------------------------------------- .../mongodb/MongoDbTailingProcess.java | 47 +++++++++----------- 1 file changed, 20 insertions(+), 27 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/d5d659eb/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbTailingProcess.java ---------------------------------------------------------------------- diff --git a/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbTailingProcess.java b/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbTailingProcess.java index 916f222..2eaf6e1 100644 --- a/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbTailingProcess.java +++ b/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbTailingProcess.java @@ -38,8 +38,8 @@ public class MongoDbTailingProcess implements Runnable { private static final String CAPPED_KEY = "capped"; public volatile boolean keepRunning = true; - private final CountDownLatch latch = new CountDownLatch(1); - + public volatile boolean stopped; // = false + private final DBCollection dbCol; private final MongoDbEndpoint endpoint; private final MongoDbTailableCursorConsumer consumer; @@ -98,30 +98,28 @@ public class MongoDbTailingProcess implements Runnable { */ @Override public void run() { - try { - while (keepRunning) { - doRun(); - // if the previous call didn't return because we have stopped running, then regenerate the cursor - if (keepRunning) { - cursor.close(); - if (LOG.isDebugEnabled()) { - LOG.debug("Regenerating cursor with lastVal: {}, waiting {}ms first", tailTracking.lastVal, cursorRegenerationDelay); - } + while (keepRunning) { + doRun(); + // if the previous call didn't return because we have stopped running, then regenerate the cursor + if (keepRunning) { + cursor.close(); + if (LOG.isDebugEnabled()) { + LOG.debug("Regenerating cursor with lastVal: {}, waiting {}ms first", tailTracking.lastVal, cursorRegenerationDelay); + } - if (cursorRegenerationDelayEnabled) { - try { - Thread.sleep(cursorRegenerationDelay); - } catch (InterruptedException e) { - // ignore - } + if (cursorRegenerationDelayEnabled) { + try { + Thread.sleep(cursorRegenerationDelay); + } catch (InterruptedException e) { + // ignore } - - cursor = initializeCursor(); } + + cursor = initializeCursor(); } - } finally { - latch.countDown(); } + + stopped = true; } protected void stop() throws Exception { @@ -134,15 +132,10 @@ public class MongoDbTailingProcess implements Runnable { cursor.close(); } // wait until the main loop acknowledges the stop - // TODO: yikes this is not good with a endless while loop - // wait for stop latch - boolean zero = latch.await(30, TimeUnit.SECONDS); + while (!stopped) { } if (LOG.isInfoEnabled()) { LOG.info("Stopped MongoDB Tailable Cursor consumer, bound to collection: {}", "db: " + dbCol.getDB() + ", col: " + dbCol.getName()); } - if (!zero) { - LOG.warn("Waited 30 seconds for MongoDB Tailable Cursor consumer to stop cleanly. Will now force stop."); - } } /**