Interface MongoConfig


@ConfigMapping(prefix="quarkus.mongodb") @ConfigRoot(phase=RUN_TIME) public interface MongoConfig
  • Field Details

  • Method Details

    • clients

      @WithParentName @WithDefaults @WithUnnamedKey("<default>") @ConfigDocMapKey("mongo-client-name") @WithUnnamedKey("<default>") Map<String,MongoClientConfig> clients()
      Configures the Mongo clients.

      The default client does not have a name, and it is configured as:

       quarkus.mongodb.connection-string = mongodb://mongo1:27017
       
      And then use Inject to inject the client:
       @Inject
       MongoClient mongoClient;
       

      Named clusters must be identified to select the right client:

       quarkus.mongodb.cluster1.connection-string = mongodb://mongo1:27017
       quarkus.mongodb.cluster2.connection-string = mongodb://mongo2:27017,mongodb://mongo3:27017
       
      And then use the MongoClientName annotation to select any of the beans: And inject the client:
       
       &#64;MongoClientName("cluster1")
       &#64;Inject
       ReactiveMongoClient mongoClientCluster1
       
       
    • useVertxDnsResolverInNativeMode

      @Deprecated @WithName("native.dns.use-vertx-dns-resolver") @WithDefault("false") boolean useVertxDnsResolverInNativeMode()
      Deprecated.
      This resolver is always used
      The default DNS resolver used to handle mongo+srv:// urls cannot be used in a native executable. This option enables a fallback to use Vert.x to resolve the server names instead of JNDI. IMPORTANT: The resolution may be different in JVM mode using the default (JNDI-based) DNS resolver, and in native mode. This feature is experimental.
    • dnsServer

      @WithName("dns.server-host") Optional<String> dnsServer()
      This property configures the DNS server. If the server is not set, it tries to read the first nameserver from /etc /resolv.conf (if the file exists), otherwise fallback to the default.
    • dnsServerPort

      @WithName("dns.server-port") OptionalInt dnsServerPort()
      This property configures the DNS server port.
    • dnsLookupTimeout

      @WithName("dns.lookup-timeout") @WithDefault("5s") Duration dnsLookupTimeout()
      If native.dns.use-vertx-dns-resolver is set to true, this property configures the DNS lookup timeout duration.
    • dnsLookupLogActivity

      @WithDefault("false") @WithName("dns.log-activity") boolean dnsLookupLogActivity()
      This property enables the logging ot the DNS lookup. It can be useful to understand why the lookup fails.
    • isDefaultClient

      static boolean isDefaultClient(String name)
    • getPropertyName

      static String getPropertyName(String name, String attribute)