Interface ReactiveMongoClient

  • All Superinterfaces:
    AutoCloseable, Closeable
    All Known Implementing Classes:
    ReactiveMongoClientImpl

    public interface ReactiveMongoClient
    extends Closeable
    A reactive Mongo client. Instances can represent either a standalone MongoDB instance, a replica set, or a sharded cluster. Instance of this class are responsible for maintaining an up-to-date state of the cluster, and possibly cache resources related to this, including background threads for monitoring, and connection pools.

    Instance of this class server as factories for ReactiveMongoDatabase instances.

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void close()
      Closes the client, which will close all underlying cached resources, including, for example, sockets and background monitoring threads.
      ReactiveMongoDatabase getDatabase​(String name)
      Retrieves a ReactiveMongoDatabase with the given name.
      io.smallrye.mutiny.Multi<String> listDatabaseNames()
      Gets a list of the database names.
      io.smallrye.mutiny.Multi<String> listDatabaseNames​(com.mongodb.reactivestreams.client.ClientSession clientSession)
      Gets a list of the database names.
      io.smallrye.mutiny.Multi<org.bson.Document> listDatabases()
      Gets the list of database descriptors.
      io.smallrye.mutiny.Multi<org.bson.Document> listDatabases​(com.mongodb.reactivestreams.client.ClientSession clientSession)
      Gets the list of databases as a stream.
      io.smallrye.mutiny.Multi<org.bson.Document> listDatabases​(com.mongodb.reactivestreams.client.ClientSession clientSession, DatabaseListOptions options)
      Gets the list of databases as a stream.
      <T> io.smallrye.mutiny.Multi<T> listDatabases​(com.mongodb.reactivestreams.client.ClientSession clientSession, Class<T> clazz)
      Gets the list of databases.
      <T> io.smallrye.mutiny.Multi<T> listDatabases​(com.mongodb.reactivestreams.client.ClientSession clientSession, Class<T> clazz, DatabaseListOptions options)
      Gets the list of databases.
      io.smallrye.mutiny.Multi<org.bson.Document> listDatabases​(DatabaseListOptions options)
      Gets the list of database descriptors.
      <T> io.smallrye.mutiny.Multi<T> listDatabases​(Class<T> clazz)
      Gets the list of databases.
      <T> io.smallrye.mutiny.Multi<T> listDatabases​(Class<T> clazz, DatabaseListOptions options)
      Gets the list of databases.
      io.smallrye.mutiny.Uni<com.mongodb.reactivestreams.client.ClientSession> startSession()
      Creates a client session.
      io.smallrye.mutiny.Uni<com.mongodb.reactivestreams.client.ClientSession> startSession​(com.mongodb.ClientSessionOptions options)
      Creates a client session.
      com.mongodb.reactivestreams.client.MongoClient unwrap()  
      io.smallrye.mutiny.Multi<com.mongodb.client.model.changestream.ChangeStreamDocument<org.bson.Document>> watch()
      Creates a change stream for this client.
      io.smallrye.mutiny.Multi<com.mongodb.client.model.changestream.ChangeStreamDocument<org.bson.Document>> watch​(com.mongodb.reactivestreams.client.ClientSession clientSession)
      Creates a change stream for this client.
      io.smallrye.mutiny.Multi<com.mongodb.client.model.changestream.ChangeStreamDocument<org.bson.Document>> watch​(com.mongodb.reactivestreams.client.ClientSession clientSession, ChangeStreamOptions options)
      Creates a change stream for this client.
      <T> io.smallrye.mutiny.Multi<com.mongodb.client.model.changestream.ChangeStreamDocument<T>> watch​(com.mongodb.reactivestreams.client.ClientSession clientSession, Class<T> clazz)
      Creates a change stream for this client.
      <T> io.smallrye.mutiny.Multi<com.mongodb.client.model.changestream.ChangeStreamDocument<T>> watch​(com.mongodb.reactivestreams.client.ClientSession clientSession, Class<T> clazz, ChangeStreamOptions options)
      Creates a change stream for this client.
      io.smallrye.mutiny.Multi<com.mongodb.client.model.changestream.ChangeStreamDocument<org.bson.Document>> watch​(com.mongodb.reactivestreams.client.ClientSession clientSession, List<? extends org.bson.conversions.Bson> pipeline)
      Creates a change stream for this client.
      io.smallrye.mutiny.Multi<com.mongodb.client.model.changestream.ChangeStreamDocument<org.bson.Document>> watch​(com.mongodb.reactivestreams.client.ClientSession clientSession, List<? extends org.bson.conversions.Bson> pipeline, ChangeStreamOptions options)
      Creates a change stream for this client.
      <T> io.smallrye.mutiny.Multi<com.mongodb.client.model.changestream.ChangeStreamDocument<T>> watch​(com.mongodb.reactivestreams.client.ClientSession clientSession, List<? extends org.bson.conversions.Bson> pipeline, Class<T> clazz)
      Creates a change stream for this client.
      <T> io.smallrye.mutiny.Multi<com.mongodb.client.model.changestream.ChangeStreamDocument<T>> watch​(com.mongodb.reactivestreams.client.ClientSession clientSession, List<? extends org.bson.conversions.Bson> pipeline, Class<T> clazz, ChangeStreamOptions options)
      Creates a change stream for this client.
      io.smallrye.mutiny.Multi<com.mongodb.client.model.changestream.ChangeStreamDocument<org.bson.Document>> watch​(ChangeStreamOptions options)
      Creates a change stream for this client.
      <T> io.smallrye.mutiny.Multi<com.mongodb.client.model.changestream.ChangeStreamDocument<T>> watch​(Class<T> clazz)
      Creates a change stream for this client.
      <T> io.smallrye.mutiny.Multi<com.mongodb.client.model.changestream.ChangeStreamDocument<T>> watch​(Class<T> clazz, ChangeStreamOptions options)
      Creates a change stream for this client.
      io.smallrye.mutiny.Multi<com.mongodb.client.model.changestream.ChangeStreamDocument<org.bson.Document>> watch​(List<? extends org.bson.conversions.Bson> pipeline)
      Creates a change stream for this client.
      io.smallrye.mutiny.Multi<com.mongodb.client.model.changestream.ChangeStreamDocument<org.bson.Document>> watch​(List<? extends org.bson.conversions.Bson> pipeline, ChangeStreamOptions options)
      Creates a change stream for this client.
      <T> io.smallrye.mutiny.Multi<com.mongodb.client.model.changestream.ChangeStreamDocument<T>> watch​(List<? extends org.bson.conversions.Bson> pipeline, Class<T> clazz)
      Creates a change stream for this client.
      <T> io.smallrye.mutiny.Multi<com.mongodb.client.model.changestream.ChangeStreamDocument<T>> watch​(List<? extends org.bson.conversions.Bson> pipeline, Class<T> clazz, ChangeStreamOptions options)
      Creates a change stream for this client.
    • Method Detail

      • close

        void close()
        Closes the client, which will close all underlying cached resources, including, for example, sockets and background monitoring threads.
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable
      • listDatabaseNames

        io.smallrye.mutiny.Multi<String> listDatabaseNames()
        Gets a list of the database names.
        Returns:
        a stream containing the database names, empty is none.
      • listDatabaseNames

        io.smallrye.mutiny.Multi<String> listDatabaseNames​(com.mongodb.reactivestreams.client.ClientSession clientSession)
        Gets a list of the database names.
        Parameters:
        clientSession - the client session with which to associate this operation
        Returns:
        a stream containing the database names, empty is none.
      • listDatabases

        io.smallrye.mutiny.Multi<org.bson.Document> listDatabases()
        Gets the list of database descriptors.
        Returns:
        a stream of the database, empty if none.
      • listDatabases

        io.smallrye.mutiny.Multi<org.bson.Document> listDatabases​(DatabaseListOptions options)
        Gets the list of database descriptors.
        Parameters:
        options - the stream options (max time, filter, name only...), may be null
        Returns:
        a stream of the database, empty if none.
      • listDatabases

        <T> io.smallrye.mutiny.Multi<T> listDatabases​(Class<T> clazz)
        Gets the list of databases.
        Type Parameters:
        T - the type of the class to use instead of Document.
        Parameters:
        clazz - the class to cast the database documents to
        Returns:
        the stream of database descriptors
      • listDatabases

        <T> io.smallrye.mutiny.Multi<T> listDatabases​(Class<T> clazz,
                                                      DatabaseListOptions options)
        Gets the list of databases.
        Type Parameters:
        T - the type of the class to use instead of Document.
        Parameters:
        clazz - the class to cast the database documents to
        options - the stream options
        Returns:
        the stream of database descriptors
      • listDatabases

        io.smallrye.mutiny.Multi<org.bson.Document> listDatabases​(com.mongodb.reactivestreams.client.ClientSession clientSession)
        Gets the list of databases as a stream.
        Parameters:
        clientSession - the client session with which to associate this operation
        Returns:
        the stream of database descriptors, empty if none.
      • listDatabases

        io.smallrye.mutiny.Multi<org.bson.Document> listDatabases​(com.mongodb.reactivestreams.client.ClientSession clientSession,
                                                                  DatabaseListOptions options)
        Gets the list of databases as a stream.
        Parameters:
        clientSession - the client session with which to associate this operation
        options - the stream options
        Returns:
        the stream of database descriptors, empty if none.
      • listDatabases

        <T> io.smallrye.mutiny.Multi<T> listDatabases​(com.mongodb.reactivestreams.client.ClientSession clientSession,
                                                      Class<T> clazz)
        Gets the list of databases.
        Type Parameters:
        T - the type of the class to use instead of Document.
        Parameters:
        clientSession - the client session with which to associate this operation
        clazz - the class to cast the database documents to
        Returns:
        the stream of database descriptors
      • listDatabases

        <T> io.smallrye.mutiny.Multi<T> listDatabases​(com.mongodb.reactivestreams.client.ClientSession clientSession,
                                                      Class<T> clazz,
                                                      DatabaseListOptions options)
        Gets the list of databases.
        Type Parameters:
        T - the type of the class to use instead of Document.
        Parameters:
        clientSession - the client session with which to associate this operation
        clazz - the class to cast the database documents to
        options - the stream options
        Returns:
        the stream of database descriptors
      • watch

        io.smallrye.mutiny.Multi<com.mongodb.client.model.changestream.ChangeStreamDocument<org.bson.Document>> watch()
        Creates a change stream for this client.
        Returns:
        the stream of change stream.
      • watch

        io.smallrye.mutiny.Multi<com.mongodb.client.model.changestream.ChangeStreamDocument<org.bson.Document>> watch​(ChangeStreamOptions options)
        Creates a change stream for this client.
        Parameters:
        options - the stream options
        Returns:
        the stream of change stream.
      • watch

        <T> io.smallrye.mutiny.Multi<com.mongodb.client.model.changestream.ChangeStreamDocument<T>> watch​(Class<T> clazz)
        Creates a change stream for this client.
        Type Parameters:
        T - the target document type of the iterable.
        Parameters:
        clazz - the class to decode each document into
        Returns:
        the stream of change stream.
      • watch

        <T> io.smallrye.mutiny.Multi<com.mongodb.client.model.changestream.ChangeStreamDocument<T>> watch​(Class<T> clazz,
                                                                                                          ChangeStreamOptions options)
        Creates a change stream for this client.
        Type Parameters:
        T - the target document type of the iterable.
        Parameters:
        clazz - the class to decode each document into
        options - the stream options
        Returns:
        the stream of change stream.
      • watch

        io.smallrye.mutiny.Multi<com.mongodb.client.model.changestream.ChangeStreamDocument<org.bson.Document>> watch​(List<? extends org.bson.conversions.Bson> pipeline)
        Creates a change stream for this client.
        Parameters:
        pipeline - the aggregation pipeline to apply to the change stream
        Returns:
        the stream of change stream.
      • watch

        io.smallrye.mutiny.Multi<com.mongodb.client.model.changestream.ChangeStreamDocument<org.bson.Document>> watch​(List<? extends org.bson.conversions.Bson> pipeline,
                                                                                                                      ChangeStreamOptions options)
        Creates a change stream for this client.
        Parameters:
        pipeline - the aggregation pipeline to apply to the change stream
        options - the stream options
        Returns:
        the stream of change stream.
      • watch

        <T> io.smallrye.mutiny.Multi<com.mongodb.client.model.changestream.ChangeStreamDocument<T>> watch​(List<? extends org.bson.conversions.Bson> pipeline,
                                                                                                          Class<T> clazz)
        Creates a change stream for this client.
        Type Parameters:
        T - the target document type of the iterable.
        Parameters:
        pipeline - the aggregation pipeline to apply to the change stream
        clazz - the class to decode each document into
        Returns:
        the stream of change stream.
      • watch

        <T> io.smallrye.mutiny.Multi<com.mongodb.client.model.changestream.ChangeStreamDocument<T>> watch​(List<? extends org.bson.conversions.Bson> pipeline,
                                                                                                          Class<T> clazz,
                                                                                                          ChangeStreamOptions options)
        Creates a change stream for this client.
        Type Parameters:
        T - the target document type of the iterable.
        Parameters:
        pipeline - the aggregation pipeline to apply to the change stream
        clazz - the class to decode each document into
        options - the stream options
        Returns:
        the stream of change stream.
      • watch

        io.smallrye.mutiny.Multi<com.mongodb.client.model.changestream.ChangeStreamDocument<org.bson.Document>> watch​(com.mongodb.reactivestreams.client.ClientSession clientSession)
        Creates a change stream for this client.
        Parameters:
        clientSession - the client session with which to associate this operation
        Returns:
        the stream of change stream.
      • watch

        io.smallrye.mutiny.Multi<com.mongodb.client.model.changestream.ChangeStreamDocument<org.bson.Document>> watch​(com.mongodb.reactivestreams.client.ClientSession clientSession,
                                                                                                                      ChangeStreamOptions options)
        Creates a change stream for this client.
        Parameters:
        clientSession - the client session with which to associate this operation
        options - the stream options
        Returns:
        the stream of change stream.
      • watch

        <T> io.smallrye.mutiny.Multi<com.mongodb.client.model.changestream.ChangeStreamDocument<T>> watch​(com.mongodb.reactivestreams.client.ClientSession clientSession,
                                                                                                          Class<T> clazz)
        Creates a change stream for this client.
        Type Parameters:
        T - the target document type of the iterable.
        Parameters:
        clientSession - the client session with which to associate this operation
        clazz - the class to decode each document into
        Returns:
        the stream of change stream.
      • watch

        <T> io.smallrye.mutiny.Multi<com.mongodb.client.model.changestream.ChangeStreamDocument<T>> watch​(com.mongodb.reactivestreams.client.ClientSession clientSession,
                                                                                                          Class<T> clazz,
                                                                                                          ChangeStreamOptions options)
        Creates a change stream for this client.
        Type Parameters:
        T - the target document type of the iterable.
        Parameters:
        clientSession - the client session with which to associate this operation
        clazz - the class to decode each document into
        options - the stream options
        Returns:
        the stream of change stream.
      • watch

        io.smallrye.mutiny.Multi<com.mongodb.client.model.changestream.ChangeStreamDocument<org.bson.Document>> watch​(com.mongodb.reactivestreams.client.ClientSession clientSession,
                                                                                                                      List<? extends org.bson.conversions.Bson> pipeline)
        Creates a change stream for this client.
        Parameters:
        clientSession - the client session with which to associate this operation
        pipeline - the aggregation pipeline to apply to the change stream
        Returns:
        the stream of change stream.
      • watch

        io.smallrye.mutiny.Multi<com.mongodb.client.model.changestream.ChangeStreamDocument<org.bson.Document>> watch​(com.mongodb.reactivestreams.client.ClientSession clientSession,
                                                                                                                      List<? extends org.bson.conversions.Bson> pipeline,
                                                                                                                      ChangeStreamOptions options)
        Creates a change stream for this client.
        Parameters:
        clientSession - the client session with which to associate this operation
        pipeline - the aggregation pipeline to apply to the change stream
        options - the stream options
        Returns:
        the stream of change stream.
      • watch

        <T> io.smallrye.mutiny.Multi<com.mongodb.client.model.changestream.ChangeStreamDocument<T>> watch​(com.mongodb.reactivestreams.client.ClientSession clientSession,
                                                                                                          List<? extends org.bson.conversions.Bson> pipeline,
                                                                                                          Class<T> clazz)
        Creates a change stream for this client.
        Type Parameters:
        T - the target document type of the iterable.
        Parameters:
        clientSession - the client session with which to associate this operation
        pipeline - the aggregation pipeline to apply to the change stream
        clazz - the class to decode each document into
        Returns:
        the stream of change stream.
      • watch

        <T> io.smallrye.mutiny.Multi<com.mongodb.client.model.changestream.ChangeStreamDocument<T>> watch​(com.mongodb.reactivestreams.client.ClientSession clientSession,
                                                                                                          List<? extends org.bson.conversions.Bson> pipeline,
                                                                                                          Class<T> clazz,
                                                                                                          ChangeStreamOptions options)
        Creates a change stream for this client.
        Type Parameters:
        T - the target document type of the iterable.
        Parameters:
        clientSession - the client session with which to associate this operation
        pipeline - the aggregation pipeline to apply to the change stream
        clazz - the class to decode each document into
        options - the stream options
        Returns:
        the stream of change stream.
      • startSession

        io.smallrye.mutiny.Uni<com.mongodb.reactivestreams.client.ClientSession> startSession()
        Creates a client session.
        Returns:
        a Uni completed when the session is ready to be used.
      • startSession

        io.smallrye.mutiny.Uni<com.mongodb.reactivestreams.client.ClientSession> startSession​(com.mongodb.ClientSessionOptions options)
        Creates a client session.
        Parameters:
        options - the options for the client session
        Returns:
        a Uni completed when the session is ready to be used.
      • unwrap

        com.mongodb.reactivestreams.client.MongoClient unwrap()
        Returns:
        the underlying client.