Skip to content

Quarkus Mongo Client - MongoClientCustomizer #44241

Open

Description

Describe the bug

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

Quarkus pre configure hosts of mongoclient with defaultValue 127.0.0.1:27017, when i dont set my connectionstring on properties and create a custom mongoclient config implementing the interface MongoClientCustomizer and setting the connectionstring with SRV host, the driver throw an exception because it thinks that the mongoclient is configured with two types of connectionstring.

Expected behavior

Permit creating my customized connection without setting application.properties with the host.

Actual behavior

I need to set the mongodb host on application.properties with no use in my application.

How to Reproduce?

  1. Create a class that implements MongoCustomizer:
@Override
    public MongoClientSettings.Builder customize(MongoClientSettings.Builder builder) {

            builder.applyConnectionString(
                    new com.mongodb.ConnectionString(
                            "mongodb+srv://hosttt"
                    )
            );
 

        return builder;
    }
  1. dont set mongoclient configuration on application.properties.

Output of uname -a or ver

No response

Output of java -version

No response

Quarkus version or git rev

No response

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions