Subject: [mongodb-user] Re: What happens if the database is
not available?



For example, I had an observable print something when there is an error (onError method) while inserting something with the db shutted down, but the method is never called. Shouldn’t an exception be thrown at the time I get a MongoConnection? Or the onError method called when I send an operation to a shutted down db?

Hi Victor,

You can see examples of handling observables on MongoDB Scala Driver: observables

For example :

val insertObservable: Observable[Completed] = collection.insertOne(document)

insertObservable.subscribe(new Observer[Completed] {
    override def onNext(result: Completed): Unit = println(s"onNext: $result")
    override def onError(e: Throwable): Unit = println(s"onError: $e")
    override def onComplete(): Unit = println("onComplete")
})

If you still have further questions, could you please provide:

  • MongoDB Scala driver version
  • Snippet example of test code (containing the onError)
  • How do you emulate the shutting down after the connection is established ?

Regards,
Wan

--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: https://docs.mong...

odb.com/manual/support/

---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/96faae62-6cb2-4ae4-9188-f98a42d4803d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



Programming list archiving by: Enterprise Git Hosting