Interface MongoClientConfig


public interface MongoClientConfig
  • Method Details

    • connectionString

      Optional<String> connectionString()
      Configures the connection string. The format is: mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database.collection][?options]]

      mongodb:// is a required prefix to identify that this is a string in the standard connection format.

      username:password@ are optional. If given, the driver will attempt to log in to a database after connecting to a database server. For some authentication mechanisms, only the username is specified and the password is not, in which case the ":" after the username is left off as well.

      host1 is the only required part of the connection string. It identifies a server address to connect to.

      :portX is optional and defaults to :27017 if not provided.

      /database is the name of the database to log in to and thus is only relevant if the username:password@ syntax is used. If not specified the admin database will be used by default.

      ?options are connection options. Note that if database is absent there is still a / required between the last host and the ? introducing the options. Options are name=value pairs and the pairs are separated by "&".

      An alternative format, using the mongodb+srv protocol, is:

        mongodb+srv://[username:password@]host[/[database][?options]]
       
      • mongodb+srv:// is a required prefix for this format.
      • username:password@ are optional. If given, the driver will attempt to login to a database after connecting to a database server. For some authentication mechanisms, only the username is specified and the password is not, in which case the ":" after the username is left off as well
      • host is the only required part of the URI. It identifies a single host name for which SRV records are looked up from a Domain Name Server after prefixing the host name with "_mongodb._tcp". The host/port for each SRV record becomes the seed list used to connect, as if each one were provided as host/port pair in a URI using the normal mongodb protocol.
      • /database is the name of the database to login to and thus is only relevant if the username:password@ syntax is used. If not specified the "admin" database will be used by default.
      • ?options are connection options. Note that if database is absent there is still a / required between the last host and the ? introducing the options. Options are name=value pairs and the pairs are separated by "&". Additionally with the mongodb+srv protocol, TXT records are looked up from a Domain Name Server for the given host, and the text value of each one is prepended to any options on the URI itself. Because the last specified value for any option wins, that means that options provided on the URI will override any that are provided via TXT records.
    • hosts

      @WithDefault("127.0.0.1:27017") List<String> hosts()
      Configures the MongoDB server addresses (one if single mode). The addresses are passed as host:port.
    • database

      Optional<String> database()
      Configure the database name.
    • applicationName

      Optional<String> applicationName()
      Configures the application name.
    • maxPoolSize

      OptionalInt maxPoolSize()
      Configures the maximum number of connections in the connection pool.
    • minPoolSize

      OptionalInt minPoolSize()
      Configures the minimum number of connections in the connection pool.
    • maxConnectionIdleTime

      Optional<Duration> maxConnectionIdleTime()
      Maximum idle time of a pooled connection. A connection that exceeds this limit will be closed.
    • maxConnectionLifeTime

      Optional<Duration> maxConnectionLifeTime()
      Maximum lifetime of a pooled connection. A connection that exceeds this limit will be closed.
    • maintenanceFrequency

      Optional<Duration> maintenanceFrequency()
      Configures the time period between runs of the maintenance job.
    • maintenanceInitialDelay

      Optional<Duration> maintenanceInitialDelay()
      Configures period of time to wait before running the first maintenance job on the connection pool.
    • connectTimeout

      Optional<Duration> connectTimeout()
      How long a connection can take to be opened before timing out.
    • readTimeout

      Optional<Duration> readTimeout()
      How long a socket read can take before timing out.
    • tlsInsecure

      @WithDefault("false") boolean tlsInsecure()
      If connecting with TLS, this option enables insecure TLS connections.
    • tls

      @WithDefault("false") boolean tls()
      Whether to connect using TLS.
    • replicaSetName

      Optional<String> replicaSetName()
      Implies that the hosts given are a seed list, and the driver will attempt to find all members of the set.
    • serverSelectionTimeout

      Optional<Duration> serverSelectionTimeout()
      How long the driver will wait for server selection to succeed before throwing an exception.
    • localThreshold

      Optional<Duration> localThreshold()
      When choosing among multiple MongoDB servers to send a request, the driver will only send that request to a server whose ping time is less than or equal to the server with the fastest ping time plus the local threshold.
    • heartbeatFrequency

      Optional<Duration> heartbeatFrequency()
      The frequency that the driver will attempt to determine the current state of each server in the cluster.
    • writeConcern

      Write concern
    • readConcern

      Optional<String> readConcern()
      Configures the read concern. Supported values are: local|majority|linearizable|snapshot|available
    • readPreference

      Optional<String> readPreference()
      Configures the read preference. Supported values are: primary|primaryPreferred|secondary|secondaryPreferred|nearest
    • credentials

      Credentials and authentication mechanism
    • healthDatabase

      @WithName("health.database") @WithDefault("admin") String healthDatabase()
      The database used during the readiness health checks
    • uuidRepresentation

      Optional<org.bson.UuidRepresentation> uuidRepresentation()
      Configures the UUID representation to use when encoding instances of UUID and when decoding BSON binary values with subtype of 3.