quarkiverse / quarkus-artemis

Quarkus Artemis extensions
Apache License 2.0
12 stars 13 forks source link

devservice not running when enabled is empty #568

Closed dcdh closed 2 months ago

dcdh commented 2 months ago

Hello,

Following the documentation in the source here ArtemisDevServicesBuildTimeConfig.java

    /**
     * Enable or disable Dev Services explicitly. Dev Services are automatically enabled unless
     * {@code quarkus.artemis.url} is set.
     */
    Optional<Boolean> enabled();

the dev service should be run by default when the enabled value is not defined.

However, it is not the case, because when the value is not defined the dev service will not start.

This code check if the devservice will be started or not

            if (!shadowRunTimeConfigs.getNames().contains(name) && buildTimeConfig.isEmpty()) {
                LOGGER.debugf(
                        "Not starting dev services for ActiveMQ Artemis and configuration %s, as its configuration is empty.",
                        name);
                continue;
            }

The buildTimeConfig.isEmpty() is defined this way

from ArtemisBuildTimeConfig.java

    default boolean isEmpty() {
        return enabled().isEmpty() && devservices().isEmpty() && xaEnabled().isEmpty();
    }

The devservices().isEmpty() is defined this way ArtemisDevServicesBuildTimeConfig

    default boolean isEmpty() {
        return enabled().isEmpty()
                && port().isEmpty()
                && imageName().isEmpty()
                && shared().isEmpty()
                && serviceName().isEmpty()
                && user().isEmpty()
                && password().isEmpty()
                && extraArgs().isEmpty();
    }

The enabled().isEmpty() is problematic because the buildTimeConfig.isEmpty() will always return true and so the devservice will not be started while we expect it to start because enabled has not been defined.

I guess you should define a default value to true.

Somethings this way:

Before:

    /**
     * Enable or disable Dev Services explicitly. Dev Services are automatically enabled unless
     * {@code quarkus.artemis.url} is set.
     */
    Optional<Boolean> enabled();

After:

    @WithDefault("true")
    boolean enabled();

Moreover, isEmpty may not reflect the intention. Maybe it would be nice to do the check likes it is done for a datasource

Regards, Damien

turing85 commented 2 months ago

@dcdh Can you double-check that the connection factory is visible at build-time at all as explained here? A reproducer would also help.

I have a sneaking suspicion that if the connection is visible at build-time, that the handling of env var extension at build-time might have changed, and that this broke something on our end.

dcdh commented 2 months ago

Not an issue. I confirm it is working. On our side we took some code and not all of it. I was distracted by it.