[ https://issues.apache.org/jira/browse/CAMEL-11977?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16237889#comment-16237889 ]
ASF GitHub Bot commented on CAMEL-11977: ---------------------------------------- igorko closed pull request #2075: CAMEL-11977: MongoDB Tailable cursor consumer fails to stop on shutdown URL: https://github.com/apache/camel/pull/2075 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): 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 6192949c8ef..d7018a72ccc 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 @@ -158,8 +158,8 @@ private void doRun() { boolean persistRegularly = persistRecords > 0; // while the cursor has more values, keepRunning is true and the cursorId is not 0, which symbolizes that the cursor is dead try { - while (cursor.hasNext() && keepRunning) { //cursor.getCursorId() != 0 && - DBObject dbObj = cursor.next(); + DBObject dbObj = null; + while ((dbObj = cursor.tryNext()) != null && keepRunning) { //cursor.getCursorId() != 0 && Exchange exchange = endpoint.createMongoDbExchange(dbObj); try { if (LOG.isTraceEnabled()) { ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > MongoDB Tailable cursor consumer fails to stop on shutdown > ---------------------------------------------------------- > > Key: CAMEL-11977 > URL: https://issues.apache.org/jira/browse/CAMEL-11977 > Project: Camel > Issue Type: Bug > Components: camel-mongodb, camel-mongodb3 > Affects Versions: 2.20.0 > Environment: Windows 10, Java 1.8 > Reporter: Ihor Paliichuk > Priority: Major > Fix For: 2.20.1, 2.21.0 > > > MongoDB Tailable cursor consumer fails to stop on shutdown(when using Ctrl+C) > if collection is not empty. Routes are described in xml file. > [Camel (...) thread #8 - ShutdownTask] INFO o.a.c.c.m.MongoDbTailingProcess > - Stopping MongoDB Tailable Cursor consumer, bound to collection: db: ..., > col: ... > [Camel (...) thread #8 - ShutdownTask] INFO o.a.c.c.m.MongoDbTailingProcess > - Going to wait for stopping > When collection is empty, all is ok and I see next line > [Camel (...) thread #8 - ShutdownTask] INFO o.a.c.c.m.MongoDbTailingProcess > - Stopped MongoDB Tailable Cursor consumer, bound to collection: db: ..., > col: ... -- This message was sent by Atlassian JIRA (v6.4.14#64029)