Reactivemongo限制Play 2.3的收集问题

时间:2015-06-13 04:18:57

标签: reactivemongo play-reactivemongo

我按照CappedCollection演示示例获得了一个Iteratee,消耗了Play 2.2的上限集合,没有任何问题。升级到Play 2.3后,我在尝试阻止Iteratee时遇到了一些奇怪的问题。当游戏关闭时,我挂钩到onStop并尝试停止iteratee购买呼叫运行,但无论在Await上什么,我总是遇到超时。这也发生在我使用withApplication的单元测试中。直到升级到2.3并且到reactivemongo / play2-reactive mongo“0.10.5.0.akka23”,这才能完美运行。最初,我认为Play首先关闭Akka可能是一个问题,但我已经确认ReactiveMongoPlugin设置为1200,应该在Akka之前关闭。

任何帮助将不胜感激!

Mongo版本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)


    }

//例外

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 个答案:

没有答案