Class MongoClientConfig

java.lang.Object
io.quarkus.mongodb.runtime.MongoClientConfig

public class MongoClientConfig extends Object
  • Field Details

    • 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 addresses (one if single mode). The addresses are passed as host:port.
    • database

      @ConfigItem public Optional<String> database
      Configure the database name.
    • applicationName

      @ConfigItem public Optional<String> applicationName
      Configures the application name.
    • 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.
    • connectTimeout

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

      @ConfigItem public Optional<Duration> readTimeout
      How long a socket read can take before timing out.
    • 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.
    • writeConcern

      Write concern
    • 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 preference. Supported values are: primary|primaryPreferred|secondary|secondaryPreferred|nearest
    • credentials

      @ConfigDocSection public CredentialConfig credentials
      Credentials and authentication mechanism
    • healthDatabase

      @ConfigItem(name="health.database", defaultValue="admin") public String healthDatabase
      The database used during the readiness health checks
    • uuidRepresentation

      @ConfigItem public 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.
  • Constructor Details

    • MongoClientConfig

      public MongoClientConfig()