I’m using the MongoDB Reactive Streams Java API which I implemented following this example, but I’m encountering a serious problem: sometimes, when I try to query a collection, the await
methods doesn’t work, and it hangs until the timeout is reached.
The onSubscribe
methods gets called correctly, but then neither onNext
, nor onError
nor onComplete
get called.
There doesn’t seem to be a specific circumstance causing this issue.
This is my code
MongoDatabase database = MongoDBConnector.getClient().getDatabase("myDb");
MongoCollection<Document> collection = database.getCollection("myCollection");
FindPublisher<Document> finder = collection.find(Filters.exists("myField"));
SettingSubscriber tagSub = new SettingSubscriber(finder);
//SettingsSubscriber is a subclass of ObservableSubscriber which calls publisher.subscribe(this)
tagSub.await(); //this is where it hangs
return tagSub.getWrappedData();