Class MongoClientConfig


  • public class MongoClientConfig
    extends Object
    • Field Detail

      • connectionString

        @ConfigItem
        public 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

        @ConfigItem(defaultValue="127.0.0.1:27017")
        public List<String> hosts
        Configures the MongoDB server addressed (one if single mode). The addresses are passed as host:port.
      • maxPoolSize

        @ConfigItem
        public OptionalInt maxPoolSize
        Configures the maximum number of connections in the connection pool.
      • minPoolSize

        @ConfigItem
        public OptionalInt minPoolSize
        Configures the minimum number of connections in the connection pool.
      • maxConnectionIdleTime

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

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

        @ConfigItem
        public Optional<Duration> maintenanceFrequency
        Configures the time period between runs of the maintenance job.
      • maintenanceInitialDelay

        @ConfigItem
        public Optional<Duration> maintenanceInitialDelay
        Configures period of time to wait before running the first maintenance job on the connection pool.
      • tlsInsecure

        @ConfigItem
        public boolean tlsInsecure
        If connecting with TLS, this option enables insecure TLS connections.
      • tls

        @ConfigItem
        public boolean tls
        Whether to connect using TLS.
      • replicaSetName

        @ConfigItem
        public 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

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

        @ConfigItem
        public 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

        @ConfigItem
        public Optional<Duration> heartbeatFrequency
        The frequency that the driver will attempt to determine the current state of each server in the cluster.
      • readConcern

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

        @ConfigItem
        public Optional<String> readPreference
        Configures the read preferences. Supported values are: primary|primaryPreferred|secondary|secondaryPreferred|nearest
    • Constructor Detail

      • MongoClientConfig

        public MongoClientConfig()