Reactivemongo capped collection issues with Play 2.3

127 views Asked by At

I followed the CappedCollection demo example and got an Iteratee up that consumes a capped collection with Play 2.2 and had no issues. After upgrading to Play 2.3, I am seeing strange issues when trying to stop the Iteratee. When play is shutdown i hook into onStop and try to stop the iteratee buy calling run, but I am always running into timeouts no matter what on the Await. This is also happening on my unit test that uses withApplication. This was working flawlessly until the upgrade to play 2.3 and to reactivemongo/play2-reactive mongo"0.10.5.0.akka23". Initially, I thought it could be a an issue with Play shutting down Akka first, but i have verified that ReactiveMongoPlugin is set to 1200 which should be shut down before Akka.

Any help would be appreciated thanks!

Mongo version 2.6.3

Here is my setup code 
//Some JSONCollection

           collection
           .find(Jons.obj())
           .hint(Json.obj("$natural" -> 1))
           .options(QueryOpts().tailable.awaitData)
          .cursor[Model])

        val enumerator = cursor.get.enumerate()

        iteratee = Iteratee.flatten(enumerator |>> process())
    }

    //Iteratee returned for 
    def process(): Iteratee[Model, Unit] = {
    Iteratee.foreach { model =>

          //Do something with model class
          process(model)
        }

    //Called by Global.onStop()
    def stop(): Unit=  {

        val result = iteratee.run.andThen {
          case r => saveIndex()
         } andThen {
            case Success(x) => Logger.info("Successful exit iteratee")
            case Failure(ex) => Logger.error("", ex)
         }

       //This always times out on shutdown
       Await.result(f, 10 seconds)


    }

//Exception

til.concurrent.TimeoutException: Futures timed out after [10 seconds]
        at scala.concurrent.impl.Promise$DefaultPromise.ready(Promise.scala:219) ~[scala-library-2.11.1.jar:na]
        at scala.concurrent.impl.Promise$DefaultPromise.result(Promise.scala:223) ~[scala-library-2.11.1.jar:na]
        at scala.concurrent.Await$$anonfun$result$1.apply(package.scala:111) ~[scala-library-2.11.1.jar:na]
        at scala.concurrent.BlockContext$DefaultBlockContext$.blockOn(BlockContext.scala:53) ~[scala-library-2.11.1.jar:na]
        at scala.concurrent.Await$.result(package.scala:111) ~[scala-library-2.11.1.jar:na]
0

There are 0 answers