public class MongoClientConfig extends Object
Modifier and Type | Field and Description |
---|---|
Optional<String> |
applicationName
Configures the application name.
|
Optional<String> |
connectionString
Configures the connection string.
|
Optional<Duration> |
connectTimeout
How long a connection can take to be opened before timing out.
|
CredentialConfig |
credentials
Credentials and authentication mechanism
|
Optional<String> |
database
Configure the database name.
|
Optional<Duration> |
heartbeatFrequency
The frequency that the driver will attempt to determine the current state of each server in the cluster.
|
List<String> |
hosts
Configures the MongoDB server addressed (one if single mode).
|
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.
|
Optional<Duration> |
maintenanceFrequency
Configures the time period between runs of the maintenance job.
|
Optional<Duration> |
maintenanceInitialDelay
Configures period of time to wait before running the first maintenance job on the connection pool.
|
Optional<Duration> |
maxConnectionIdleTime
Maximum idle time of a pooled connection.
|
Optional<Duration> |
maxConnectionLifeTime
Maximum life time of a pooled connection.
|
OptionalInt |
maxPoolSize
Configures the maximum number of connections in the connection pool.
|
OptionalInt |
minPoolSize
Configures the minimum number of connections in the connection pool.
|
Optional<String> |
readPreference
Configures the read preferences.
|
Optional<Duration> |
readTimeout
How long a socket read can take before timing out.
|
Optional<String> |
replicaSetName
Implies that the hosts given are a seed list, and the driver will attempt to find all members of the set.
|
Optional<Duration> |
serverSelectionTimeout
How long the driver will wait for server selection to succeed before throwing an exception.
|
boolean |
tls
Whether to connect using TLS.
|
boolean |
tlsInsecure
If connecting with TLS, this option enables insecure TLS connections.
|
OptionalInt |
waitQueueMultiple
This multiplier, multiplied with the
maxPoolSize setting, gives the maximum number of
threads that may be waiting for a connection to become available from the pool. |
Optional<Duration> |
waitQueueTimeout
The maximum wait time that a thread may wait for a connection to become available.
|
WriteConcernConfig |
writeConcern
Write concern
|
Constructor and Description |
---|
MongoClientConfig() |
@ConfigItem public Optional<String> connectionString
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 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.
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 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 "&".
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 wellhost
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.@ConfigItem(defaultValue="127.0.0.1:27017") public List<String> hosts
host:port
.@ConfigItem public Optional<String> database
@ConfigItem public Optional<String> applicationName
@ConfigItem public OptionalInt maxPoolSize
@ConfigItem public OptionalInt minPoolSize
@ConfigItem public Optional<Duration> maxConnectionIdleTime
@ConfigItem public Optional<Duration> maxConnectionLifeTime
@ConfigItem public Optional<Duration> waitQueueTimeout
@ConfigItem public Optional<Duration> maintenanceFrequency
@ConfigItem public Optional<Duration> maintenanceInitialDelay
@ConfigItem public OptionalInt waitQueueMultiple
maxPoolSize
setting, gives the maximum number of
threads that may be waiting for a connection to become available from the pool. All further threads will get an
exception right away.@ConfigItem public Optional<Duration> connectTimeout
@ConfigItem public Optional<Duration> readTimeout
@ConfigItem public boolean tlsInsecure
@ConfigItem public boolean tls
@ConfigItem public Optional<String> replicaSetName
@ConfigItem public Optional<Duration> serverSelectionTimeout
@ConfigItem public Optional<Duration> localThreshold
@ConfigItem public Optional<Duration> heartbeatFrequency
@ConfigDocSection public WriteConcernConfig writeConcern
@ConfigItem public Optional<String> readPreference
primary|primaryPreferred|secondary|secondaryPreferred|nearest
@ConfigDocSection public CredentialConfig credentials
Copyright © 2020 JBoss by Red Hat. All rights reserved.