diff --git a/core/deployment/src/main/java/io/quarkus/artemis/core/deployment/ArtemisCoreProcessor.java b/core/deployment/src/main/java/io/quarkus/artemis/core/deployment/ArtemisCoreProcessor.java index 4f89d3c5..26ad36e4 100644 --- a/core/deployment/src/main/java/io/quarkus/artemis/core/deployment/ArtemisCoreProcessor.java +++ b/core/deployment/src/main/java/io/quarkus/artemis/core/deployment/ArtemisCoreProcessor.java @@ -23,7 +23,6 @@ import org.jboss.logging.Logger; import io.quarkus.arc.deployment.SyntheticBeanBuildItem; -import io.quarkus.artemis.core.runtime.ArtemisBuildTimeConfig; import io.quarkus.artemis.core.runtime.ArtemisBuildTimeConfigs; import io.quarkus.artemis.core.runtime.ArtemisCoreRecorder; import io.quarkus.artemis.core.runtime.ArtemisRuntimeConfigs; @@ -77,7 +76,7 @@ NativeImageConfigBuildItem config() { ArtemisBootstrappedBuildItem build( CombinedIndexBuildItem indexBuildItem, BuildProducer reflectiveClass, - ShadowRunTimeConfigs shadowRunTimeConfigs, + ShadowRuntimeConfigs shadowRunTimeConfigs, ArtemisBuildTimeConfigs buildTimeConfigs) { Collection connectorFactories = indexBuildItem.getIndex() .getAllKnownImplementors(DotName.createSimple(ConnectorFactory.class.getName())); @@ -90,12 +89,12 @@ ArtemisBootstrappedBuildItem build( addBuiltinReflectiveBuildItems(reflectiveClass, BUILTIN_LOADBALANCING_POLICIES); HashSet names = new HashSet<>(shadowRunTimeConfigs.getNames()); HashSet disabled = new HashSet<>(); - for (var entry : buildTimeConfigs.getAllConfigs().entrySet()) { + for (var entry : buildTimeConfigs.configs().entrySet()) { if (entry.getValue().isDisabled()) { disabled.add(entry.getKey()); } } - names.addAll(buildTimeConfigs.getAllConfigs().keySet()); + names.addAll(buildTimeConfigs.getNames()); names.removeAll(disabled); return new ArtemisBootstrappedBuildItem(names); } @@ -106,7 +105,7 @@ ArtemisBootstrappedBuildItem build( ArtemisCoreConfiguredBuildItem configure( ArtemisCoreRecorder recorder, ArtemisRuntimeConfigs runtimeConfigs, - ShadowRunTimeConfigs shadowRunTimeConfigs, + ShadowRuntimeConfigs shadowRunTimeConfigs, ArtemisBuildTimeConfigs buildTimeConfigs, ArtemisBootstrappedBuildItem bootstrap, BuildProducer syntheticBeanProducer, @@ -121,7 +120,7 @@ ArtemisCoreConfiguredBuildItem configure( boolean isSoleServerLocator = bootstrap.getConfigurationNames().size() == 1; for (String name : bootstrap.getConfigurationNames()) { if (!shadowRunTimeConfigs.getNames().contains(name) - && buildTimeConfigs.getAllConfigs().getOrDefault(name, new ArtemisBuildTimeConfig()).isEmpty()) { + && buildTimeConfigs.configs().get(name).isEmpty()) { continue; } Supplier supplier = recorder.getServerLocatorSupplier( diff --git a/core/deployment/src/main/java/io/quarkus/artemis/core/deployment/DevServicesArtemisProcessor.java b/core/deployment/src/main/java/io/quarkus/artemis/core/deployment/DevServicesArtemisProcessor.java index 9f7e5e3d..a64c2ac9 100644 --- a/core/deployment/src/main/java/io/quarkus/artemis/core/deployment/DevServicesArtemisProcessor.java +++ b/core/deployment/src/main/java/io/quarkus/artemis/core/deployment/DevServicesArtemisProcessor.java @@ -63,7 +63,7 @@ public List startArtemisDevService( DockerStatusBuildItem dockerStatusBuildItem, LaunchModeBuildItem launchMode, ArtemisBootstrappedBuildItem bootstrap, - ShadowRunTimeConfigs shadowRunTimeConfigs, + ShadowRuntimeConfigs shadowRunTimeConfigs, ArtemisBuildTimeConfigs buildConfigs, List devServicesSharedNetworkBuildItem, Optional consoleInstalledBuildItem, @@ -72,8 +72,7 @@ public List startArtemisDevService( GlobalDevServicesConfig devServicesConfig) { ArrayList results = new ArrayList<>(); for (String name : bootstrap.getConfigurationNames()) { - ArtemisBuildTimeConfig buildTimeConfig = buildConfigs.getAllConfigs().getOrDefault(name, - new ArtemisBuildTimeConfig()); + ArtemisBuildTimeConfig buildTimeConfig = buildConfigs.configs().get(name); boolean isUrlEmpty = shadowRunTimeConfigs.isUrlEmpty(name); if (!shadowRunTimeConfigs.getNames().contains(name) && buildTimeConfig.isEmpty()) { LOGGER.debugf( @@ -120,29 +119,28 @@ private static DevServicesResultBuildItem start( cfgs.clear(); } - StartupLogCompressor compressor = new StartupLogCompressor( - (launchMode.isTest() ? "(test) " : "") + "ActiveMQ Artemis Dev Services Starting:", - consoleInstalledBuildItem, loggingSetupBuildItem); if (configuration != null) { - try { - // devServices - RunningDevService service = startArtemis( - name, - dockerStatusBuildItem, - configuration, - launchMode, - devServicesConfig.timeout); - if (service != null) { - devServices.put(name, service); - } - if (devServices.get(name) == null) { + try (StartupLogCompressor compressor = new StartupLogCompressor( + (launchMode.isTest() ? "(test) " : "") + "ActiveMQ Artemis Dev Services Starting:", + consoleInstalledBuildItem, loggingSetupBuildItem)) { + try { + // devServices + RunningDevService service = startArtemis( + name, + dockerStatusBuildItem, + configuration, + launchMode, + devServicesConfig.timeout); + if (service != null) { + devServices.put(name, service); + } + if (devServices.get(name) == null) { + compressor.closeAndDumpCaptured(); + } + } catch (Throwable t) { compressor.closeAndDumpCaptured(); - } else { - compressor.close(); + throw t instanceof RuntimeException ? (RuntimeException) t : new RuntimeException(t); } - } catch (Throwable t) { - compressor.closeAndDumpCaptured(); - throw t instanceof RuntimeException ? (RuntimeException) t : new RuntimeException(t); } } @@ -287,7 +285,7 @@ private static final class ArtemisDevServiceCfg { public ArtemisDevServiceCfg(ArtemisBuildTimeConfig config, String name, boolean isUrlEmpty) { ArtemisDevServicesBuildTimeConfig devServicesConfig = config.getDevservices(); - this.devServicesEnabled = devServicesConfig.enabled.orElse(isUrlEmpty); + this.devServicesEnabled = devServicesConfig.enabled().orElse(isUrlEmpty); this.imageName = devServicesConfig.getImageName(); this.fixedExposedPort = devServicesConfig.getPort(); this.shared = devServicesConfig.isShared(); diff --git a/core/deployment/src/main/java/io/quarkus/artemis/core/deployment/ShadowRunTimeConfigs.java b/core/deployment/src/main/java/io/quarkus/artemis/core/deployment/ShadowRunTimeConfigs.java deleted file mode 100644 index 7d05621f..00000000 --- a/core/deployment/src/main/java/io/quarkus/artemis/core/deployment/ShadowRunTimeConfigs.java +++ /dev/null @@ -1,71 +0,0 @@ -package io.quarkus.artemis.core.deployment; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Optional; -import java.util.Set; - -import io.quarkus.artemis.core.runtime.ArtemisUtil; -import io.quarkus.runtime.annotations.ConfigItem; -import io.quarkus.runtime.annotations.ConfigPhase; -import io.quarkus.runtime.annotations.ConfigRoot; - -/** - * This class is a build-time mirror/shadow of {@link io.quarkus.artemis.core.runtime.ArtemisRuntimeConfigs} to make the - * configuration properties accessible at build-time. - * - *

- * We use this configuration to access the configuration structure, and to extract the names of configurations - * present at build-time, so we can create the {@link org.apache.activemq.artemis.api.core.client.ServerLocator} / - * {@link jakarta.jms.ConnectionFactory} beans. Most importantly, we only query the presence of keys and/or values, - * we do not access values, since they could change at runtime. - */ -@SuppressWarnings("OptionalUsedAsFieldOrParameterType") -@ConfigRoot(name = "artemis", phase = ConfigPhase.BUILD_TIME) -public class ShadowRunTimeConfigs { - @ConfigItem(name = ConfigItem.PARENT, generateDocumentation = false) - protected ShadowRuntimeConfig defaultConfig; - - @ConfigItem(name = ConfigItem.PARENT, generateDocumentation = false) - protected Map namedConfigs = new HashMap<>(); - - @ConfigItem(name = "health.external.enabled", generateDocumentation = false) - protected Optional healthExternalEnabled = Optional.empty(); - - public ShadowRuntimeConfig getDefaultConfig() { - return defaultConfig; - } - - private Map getNamedConfigs() { - return namedConfigs; - } - - private Map getAllConfigs() { - HashMap allConfigs = new HashMap<>(getNamedConfigs()); - if (getDefaultConfig() != null && !getDefaultConfig().isEmpty()) { - allConfigs.put(ArtemisUtil.DEFAULT_CONFIG_NAME, getDefaultConfig()); - } - return allConfigs; - } - - public boolean isUrlEmpty(String name) { - return getAllConfigs().getOrDefault(name, new ShadowRuntimeConfig()).isUrlEmpty(); - } - - public Set getNames() { - HashSet names = new HashSet<>(); - for (var entry : getAllConfigs().entrySet()) { - if (entry.getValue().isPresent()) { - names.add(entry.getKey()); - } - } - return names; - } - - public boolean isEmpty() { - return defaultConfig.isEmpty() - && namedConfigs.isEmpty() - && healthExternalEnabled.isEmpty(); - } -} diff --git a/core/deployment/src/main/java/io/quarkus/artemis/core/deployment/ShadowRuntimeConfig.java b/core/deployment/src/main/java/io/quarkus/artemis/core/deployment/ShadowRuntimeConfig.java index 4e318f4e..61485c79 100644 --- a/core/deployment/src/main/java/io/quarkus/artemis/core/deployment/ShadowRuntimeConfig.java +++ b/core/deployment/src/main/java/io/quarkus/artemis/core/deployment/ShadowRuntimeConfig.java @@ -3,7 +3,6 @@ import java.util.Optional; import io.quarkus.runtime.annotations.ConfigGroup; -import io.quarkus.runtime.annotations.ConfigItem; /** * This class is a build-time mirror/shadow of {@link io.quarkus.artemis.core.runtime.ArtemisRuntimeConfig} to make the @@ -15,27 +14,52 @@ * {@link jakarta.jms.ConnectionFactory} beans. Most importantly, we only query the presence of keys and/or values, * we do not access values, since they could change at runtime. */ -@SuppressWarnings("OptionalUsedAsFieldOrParameterType") @ConfigGroup -public class ShadowRuntimeConfig { - @ConfigItem(generateDocumentation = false) - protected Optional url = Optional.empty(); +public interface ShadowRuntimeConfig { + /** + * Artemis connection url + * + * @deprecated since 3.1.3, to suppress doc generation + */ + @Deprecated(since = "3.1.3") + Optional url(); - @ConfigItem(generateDocumentation = false) - protected Optional username = Optional.empty(); + /** + * Username for authentication, only used with JMS + * + * @deprecated since 3.1.3, to suppress doc generation + */ + @Deprecated(since = "3.1.3") + Optional username(); - @ConfigItem(generateDocumentation = false) - protected Optional password = Optional.empty(); + /** + * Password for authentication, only used with JMS + * + * @deprecated since 3.1.3, to suppress doc generation + */ + @Deprecated(since = "3.1.3") + Optional password(); - boolean isUrlEmpty() { - return url.isEmpty(); + /** + * Whether this particular data source should be excluded from the health check if + * the general health check for data sources is enabled. + *

+ * By default, the health check includes all configured data sources (if it is enabled). + * + * @deprecated since 3.1.3, to suppress doc generation + */ + @Deprecated(since = "3.1.3") + Optional healthExclude(); + + default boolean isUrlEmpty() { + return url().isEmpty(); } - public boolean isEmpty() { - return url.isEmpty() && username.isEmpty() && password.isEmpty(); + default boolean isEmpty() { + return url().isEmpty() && username().isEmpty() && password().isEmpty() && healthExclude().isEmpty(); } - public boolean isPresent() { + default boolean isPresent() { return !isEmpty(); } } diff --git a/core/deployment/src/main/java/io/quarkus/artemis/core/deployment/ShadowRuntimeConfigs.java b/core/deployment/src/main/java/io/quarkus/artemis/core/deployment/ShadowRuntimeConfigs.java new file mode 100644 index 00000000..876b7177 --- /dev/null +++ b/core/deployment/src/main/java/io/quarkus/artemis/core/deployment/ShadowRuntimeConfigs.java @@ -0,0 +1,72 @@ +package io.quarkus.artemis.core.deployment; + +import java.util.HashSet; +import java.util.Map; +import java.util.Optional; +import java.util.Set; + +import io.quarkus.artemis.core.runtime.ArtemisUtil; +import io.quarkus.runtime.annotations.ConfigPhase; +import io.quarkus.runtime.annotations.ConfigRoot; +import io.smallrye.config.ConfigMapping; +import io.smallrye.config.WithDefaults; +import io.smallrye.config.WithName; +import io.smallrye.config.WithParentName; +import io.smallrye.config.WithUnnamedKey; + +/** + * This class is a build-time mirror/shadow of {@link io.quarkus.artemis.core.runtime.ArtemisRuntimeConfigs} to make the + * configuration properties accessible at build-time. + * + *

+ * We use this configuration to access the configuration structure, and to extract the names of configurations + * present at build-time, so we can create the {@link org.apache.activemq.artemis.api.core.client.ServerLocator} / + * {@link jakarta.jms.ConnectionFactory} beans. Most importantly, we only query the presence of keys and/or values, + * we do not access values, since they could change at runtime. + */ +@ConfigMapping(prefix = "quarkus.artemis") +@ConfigRoot(phase = ConfigPhase.BUILD_TIME) +public interface ShadowRuntimeConfigs { + /** + * Configurations + * + * @deprecated since 3.1.3, to suppress doc generation + */ + @WithParentName + @WithUnnamedKey(ArtemisUtil.DEFAULT_CONFIG_NAME) + @WithDefaults + @Deprecated(since = "3.1.3") + Map configs(); + + /** + * Whether configurations ({@link org.apache.activemq.artemis.api.core.client.ServerLocator}s in case of the + * {@code artemis-core} extension, {@link jakarta.jms.ConnectionFactory}s in case of the + * {@code artemis-jms} extension) should be included in the health check. Defaults to {@code true} if not set. + * + * @deprecated since 3.1.3, to suppress doc generation + */ + @Deprecated(since = "3.1.3") + @WithName("health.external.enabled") + Optional healthExternalEnabled(); + + default boolean isUrlEmpty(String name) { + return configs().get(name).isUrlEmpty(); + } + + default Set getNames() { + HashSet names = new HashSet<>(); + for (var entry : configs().entrySet()) { + if (entry.getValue().isPresent()) { + names.add(entry.getKey()); + } + } + return names; + } + + default boolean isEmpty() { + Boolean hasNoConfig = configs().values().stream() + .map(ShadowRuntimeConfig::isEmpty) + .reduce(true, Boolean::logicalAnd); + return hasNoConfig && healthExternalEnabled().isEmpty(); + } +} diff --git a/core/deployment/src/main/java/io/quarkus/artemis/core/deployment/health/ArtemisHealthProcessor.java b/core/deployment/src/main/java/io/quarkus/artemis/core/deployment/health/ArtemisHealthProcessor.java index a61ba3b2..5c4ab37a 100644 --- a/core/deployment/src/main/java/io/quarkus/artemis/core/deployment/health/ArtemisHealthProcessor.java +++ b/core/deployment/src/main/java/io/quarkus/artemis/core/deployment/health/ArtemisHealthProcessor.java @@ -10,7 +10,7 @@ import io.quarkus.arc.deployment.SyntheticBeanBuildItem; import io.quarkus.artemis.core.deployment.ArtemisBootstrappedBuildItem; import io.quarkus.artemis.core.deployment.ArtemisJmsBuildItem; -import io.quarkus.artemis.core.deployment.ShadowRunTimeConfigs; +import io.quarkus.artemis.core.deployment.ShadowRuntimeConfigs; import io.quarkus.artemis.core.runtime.ArtemisBuildTimeConfig; import io.quarkus.artemis.core.runtime.ArtemisBuildTimeConfigs; import io.quarkus.artemis.core.runtime.ArtemisUtil; @@ -24,7 +24,6 @@ import io.quarkus.deployment.annotations.Record; import io.quarkus.smallrye.health.deployment.spi.HealthBuildItem; -@SuppressWarnings("OptionalUsedAsFieldOrParameterType") public class ArtemisHealthProcessor { @SuppressWarnings("unused") @Record(ExecutionTime.STATIC_INIT) @@ -32,7 +31,7 @@ public class ArtemisHealthProcessor { ArtemisHealthSupportBuildItem healthSupport( Capabilities capabilities, ArtemisBootstrappedBuildItem bootstrap, - ShadowRunTimeConfigs shadowRunTimeConfigs, + ShadowRuntimeConfigs shadowRunTimeConfigs, ArtemisBuildTimeConfigs buildTimeConfigs, BuildProducer syntheticBeanProducer, ArtemisHealthSupportRecorder recorder) { @@ -52,22 +51,20 @@ ArtemisHealthSupportBuildItem healthSupport( private static Set processConfigs( Set names, - ShadowRunTimeConfigs shadowRunTimeConfigs, + ShadowRuntimeConfigs shadowRunTimeConfigs, ArtemisBuildTimeConfigs buildTimeConfigs) { Set excluded = new HashSet<>(); - Map allBuildTimeConfigs = Optional.ofNullable(buildTimeConfigs.getAllConfigs()) - .orElse(Map.of()); + Map allBuildTimeConfigs = buildTimeConfigs.configs(); for (String name : names) { - ArtemisBuildTimeConfig buildTimeConfig = allBuildTimeConfigs.getOrDefault(name, new ArtemisBuildTimeConfig()); - if ((ArtemisUtil.isDefault(name) && !shadowRunTimeConfigs.getNames().contains(name) && buildTimeConfig.isEmpty()) - || buildTimeConfig.isHealthExclude()) { + ArtemisBuildTimeConfig buildTimeConfig = allBuildTimeConfigs.get(name); + if ((ArtemisUtil.isDefault(name) && !shadowRunTimeConfigs.getNames().contains(name) && buildTimeConfig.isEmpty())) { excluded.add(name); } } return excluded; } - @SuppressWarnings("unused") + @SuppressWarnings({ "OptionalUsedAsFieldOrParameterType", "unused" }) @BuildStep HealthBuildItem healthChecks( Capabilities capabilities, diff --git a/core/runtime/src/main/java/io/quarkus/artemis/core/runtime/ArtemisBuildTimeConfig.java b/core/runtime/src/main/java/io/quarkus/artemis/core/runtime/ArtemisBuildTimeConfig.java index 0253e571..d5aae87b 100644 --- a/core/runtime/src/main/java/io/quarkus/artemis/core/runtime/ArtemisBuildTimeConfig.java +++ b/core/runtime/src/main/java/io/quarkus/artemis/core/runtime/ArtemisBuildTimeConfig.java @@ -3,65 +3,47 @@ import java.util.Optional; import io.quarkus.runtime.annotations.ConfigGroup; -import io.quarkus.runtime.annotations.ConfigItem; -@SuppressWarnings("OptionalUsedAsFieldOrParameterType") @ConfigGroup -public class ArtemisBuildTimeConfig { +public interface ArtemisBuildTimeConfig { /** * Whether to enable this configuration. *

* Is enabled by default. */ - @ConfigItem - public Optional enabled = Optional.empty(); + Optional enabled(); /** * Configuration for DevServices. DevServices allows Quarkus to automatically start ActiveMQ Artemis in dev and test mode. */ - @ConfigItem - public ArtemisDevServicesBuildTimeConfig devservices = new ArtemisDevServicesBuildTimeConfig(); - - /** - * Whether this particular data source should be excluded from the health check if - * the general health check for data sources is enabled. - *

- * By default, the health check includes all configured data sources (if it is enabled). - */ - @ConfigItem - public Optional healthExclude = Optional.empty(); + ArtemisDevServicesBuildTimeConfig devservices(); /** * Support to expose {@link jakarta.jms.XAConnectionFactory}. Is not activated by default. */ - @ConfigItem - public Optional xaEnabled = Optional.empty(); + Optional xaEnabled(); - public boolean isEnabled() { - return enabled.orElse(true); + default boolean isEnabled() { + return enabled().orElse(true); } - public boolean isDisabled() { + default boolean isDisabled() { return !isEnabled(); } - public ArtemisDevServicesBuildTimeConfig getDevservices() { - return devservices; - } - - public boolean isHealthExclude() { - return healthExclude.orElse(false); + default ArtemisDevServicesBuildTimeConfig getDevservices() { + return devservices(); } - public boolean isXaEnabled() { - return xaEnabled.orElse(false); + default boolean isXaEnabled() { + return xaEnabled().orElse(false); } - public boolean isEmpty() { - return enabled.isEmpty() && devservices.isEmpty() && healthExclude.isEmpty() && xaEnabled.isEmpty(); + default boolean isEmpty() { + return enabled().isEmpty() && devservices().isEmpty() && xaEnabled().isEmpty(); } - public boolean isPresent() { + default boolean isPresent() { return !isEmpty(); } } diff --git a/core/runtime/src/main/java/io/quarkus/artemis/core/runtime/ArtemisBuildTimeConfigs.java b/core/runtime/src/main/java/io/quarkus/artemis/core/runtime/ArtemisBuildTimeConfigs.java index 6c8767eb..0c7a2a62 100644 --- a/core/runtime/src/main/java/io/quarkus/artemis/core/runtime/ArtemisBuildTimeConfigs.java +++ b/core/runtime/src/main/java/io/quarkus/artemis/core/runtime/ArtemisBuildTimeConfigs.java @@ -1,63 +1,59 @@ package io.quarkus.artemis.core.runtime; -import java.util.HashMap; +import java.util.HashSet; import java.util.Map; import java.util.Optional; +import java.util.Set; import io.quarkus.runtime.annotations.ConfigDocMapKey; import io.quarkus.runtime.annotations.ConfigDocSection; -import io.quarkus.runtime.annotations.ConfigItem; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; - -@SuppressWarnings("OptionalUsedAsFieldOrParameterType") -@ConfigRoot(name = "artemis", phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) -public class ArtemisBuildTimeConfigs { +import io.smallrye.config.ConfigMapping; +import io.smallrye.config.WithDefaults; +import io.smallrye.config.WithName; +import io.smallrye.config.WithParentName; +import io.smallrye.config.WithUnnamedKey; + +@ConfigMapping(prefix = "quarkus.artemis") +@ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) +public interface ArtemisBuildTimeConfigs { /** - * The default config - */ - @ConfigItem(name = ConfigItem.PARENT) - public ArtemisBuildTimeConfig defaultConfig = new ArtemisBuildTimeConfig(); - - /** - * Additional named configs + * Configurations */ @ConfigDocSection @ConfigDocMapKey("configuration-name") - @ConfigItem(name = ConfigItem.PARENT) - public Map namedConfigs = new HashMap<>(); + @WithParentName + @WithDefaults + @WithUnnamedKey(ArtemisUtil.DEFAULT_CONFIG_NAME) + Map configs(); /** * Whether a health check is published in case the smallrye-health extension is present. *

* This is a global setting and is not specific to a datasource. */ - @ConfigItem(name = "health.enabled") - public Optional healthEnabled = Optional.empty(); - - public ArtemisBuildTimeConfig getDefaultConfig() { - return defaultConfig; - } - - private Map getNamedConfigs() { - return namedConfigs; - } - - public Map getAllConfigs() { - HashMap allConfigs = new HashMap<>(getNamedConfigs()); - if (getDefaultConfig() != null && !getDefaultConfig().isEmpty()) { - allConfigs.put(ArtemisUtil.DEFAULT_CONFIG_NAME, getDefaultConfig()); + @WithName("health.enabled") + Optional healthEnabled(); + + default Set getNames() { + HashSet names = new HashSet<>(); + for (var entry : configs().entrySet()) { + if (entry.getValue().isPresent()) { + names.add(entry.getKey()); + } } - return allConfigs; + return names; } - public boolean isHealthEnabled() { - return healthEnabled.orElse(true); + default boolean isHealthEnabled() { + return healthEnabled().orElse(true); } - public boolean isEmpty() { - return defaultConfig.isEmpty() - && namedConfigs.isEmpty() - && healthEnabled.isEmpty(); + default boolean isEmpty() { + Boolean hasNoConfig = configs().values().stream() + .map(ArtemisBuildTimeConfig::isEmpty) + .reduce(true, Boolean::logicalAnd); + return hasNoConfig && healthEnabled().isEmpty(); } } diff --git a/core/runtime/src/main/java/io/quarkus/artemis/core/runtime/ArtemisCoreRecorder.java b/core/runtime/src/main/java/io/quarkus/artemis/core/runtime/ArtemisCoreRecorder.java index 6d555c76..ea756ee4 100644 --- a/core/runtime/src/main/java/io/quarkus/artemis/core/runtime/ArtemisCoreRecorder.java +++ b/core/runtime/src/main/java/io/quarkus/artemis/core/runtime/ArtemisCoreRecorder.java @@ -14,9 +14,8 @@ public Supplier getServerLocatorSupplier( String name, ArtemisRuntimeConfigs runtimeConfigs, ArtemisBuildTimeConfigs buildTimeConfigs) { - ArtemisRuntimeConfig runtimeConfig = runtimeConfigs.getAllConfigs().getOrDefault(name, new ArtemisRuntimeConfig()); - ArtemisBuildTimeConfig buildTimeConfig = buildTimeConfigs.getAllConfigs().getOrDefault(name, - new ArtemisBuildTimeConfig()); + ArtemisRuntimeConfig runtimeConfig = runtimeConfigs.configs().get(name); + ArtemisBuildTimeConfig buildTimeConfig = buildTimeConfigs.configs().get(name); ArtemisUtil.validateIntegrity(name, runtimeConfig, buildTimeConfig); ServerLocator serverLocator = Objects.requireNonNull(getServerLocator(runtimeConfig)); return () -> serverLocator; diff --git a/core/runtime/src/main/java/io/quarkus/artemis/core/runtime/ArtemisDevServicesBuildTimeConfig.java b/core/runtime/src/main/java/io/quarkus/artemis/core/runtime/ArtemisDevServicesBuildTimeConfig.java index 002c4da8..0de25f10 100644 --- a/core/runtime/src/main/java/io/quarkus/artemis/core/runtime/ArtemisDevServicesBuildTimeConfig.java +++ b/core/runtime/src/main/java/io/quarkus/artemis/core/runtime/ArtemisDevServicesBuildTimeConfig.java @@ -3,33 +3,28 @@ import java.util.Optional; import io.quarkus.runtime.annotations.ConfigGroup; -import io.quarkus.runtime.annotations.ConfigItem; -@SuppressWarnings("OptionalUsedAsFieldOrParameterType") @ConfigGroup -public class ArtemisDevServicesBuildTimeConfig { +public interface ArtemisDevServicesBuildTimeConfig { /** * Enable or disable Dev Services explicitly. Dev Services are automatically enabled unless * {@code quarkus.artemis.url} is set. */ - @ConfigItem - public Optional enabled = Optional.empty(); + Optional enabled(); /** * Optional fixed port the dev service will listen to. *

* If not defined, the port will be chosen randomly. */ - @ConfigItem - public Optional port = Optional.empty(); + Optional port(); /** * The ActiveMQ Artemis container image to use. *

* Defaults to {@code quay.io/artemiscloud/activemq-artemis-broker:artemis.2.31.0} */ - @ConfigItem - public Optional imageName = Optional.empty(); + Optional imageName(); /** * Indicates if the ActiveMQ Artemis broker managed by Quarkus Dev Services is shared. @@ -43,8 +38,7 @@ public class ArtemisDevServicesBuildTimeConfig { *

* Container sharing is only used in dev mode. */ - @ConfigItem - public Optional shared = Optional.empty(); + Optional shared(); /** * The value of the {@code quarkus-dev-service-artemis} label attached to the started container. @@ -56,68 +50,64 @@ public class ArtemisDevServicesBuildTimeConfig { *

* This property is used when you need multiple shared ActiveMQ Artemis brokers. */ - @ConfigItem - public Optional serviceName = Optional.empty(); + Optional serviceName(); /** * User to start artemis broker. Defaults to {@code admin} if not set. */ - @ConfigItem - public Optional user = Optional.empty(); + Optional user(); /** * Password to start artemis broker. Defaults to {@code admin} whne not set. */ - @ConfigItem - public Optional password = Optional.empty(); + Optional password(); /** * The value of the {@code AMQ_EXTRA_ARGS} environment variable to pass to the container. Defaults to * {@code --no-autotune --mapped --no-fsync} when not set. */ - @ConfigItem - public Optional extraArgs = Optional.empty(); + Optional extraArgs(); - public boolean isEnabled() { - return enabled.orElse(true); + default boolean isEnabled() { + return enabled().orElse(true); } - public int getPort() { - return port.orElse(0); + default int getPort() { + return port().orElse(0); } - public String getImageName() { - return imageName.orElse("quay.io/artemiscloud/activemq-artemis-broker:artemis.2.31.0"); + default String getImageName() { + return imageName().orElse("quay.io/artemiscloud/activemq-artemis-broker:artemis.2.31.0"); } - public boolean isShared() { - return shared.orElse(true); + default boolean isShared() { + return shared().orElse(true); } - public String getServiceName() { - return serviceName.orElse("artemis"); + default String getServiceName() { + return serviceName().orElse("artemis"); } - public String getUser() { - return user.orElse("admin"); + default String getUser() { + return user().orElse("admin"); } - public String getPassword() { - return password.orElse("admin"); + default String getPassword() { + return password().orElse("admin"); } - public String getExtraArgs() { - return extraArgs.orElse("--no-autotune --mapped --no-fsync"); + default String getExtraArgs() { + return extraArgs().orElse("--no-autotune --mapped --no-fsync"); } - public boolean isEmpty() { - return enabled.isEmpty() - && port.isEmpty() - && imageName.isEmpty() - && shared.isEmpty() - && serviceName.isEmpty() - && user.isEmpty() - && password.isEmpty() - && extraArgs.isEmpty(); + default boolean isEmpty() { + return enabled().isEmpty() + && port().isEmpty() + && imageName().isEmpty() + && shared().isEmpty() + && serviceName().isEmpty() + && user().isEmpty() + && password().isEmpty() + && extraArgs().isEmpty(); } } diff --git a/core/runtime/src/main/java/io/quarkus/artemis/core/runtime/ArtemisRuntimeConfig.java b/core/runtime/src/main/java/io/quarkus/artemis/core/runtime/ArtemisRuntimeConfig.java index c036fbbf..87076c63 100644 --- a/core/runtime/src/main/java/io/quarkus/artemis/core/runtime/ArtemisRuntimeConfig.java +++ b/core/runtime/src/main/java/io/quarkus/artemis/core/runtime/ArtemisRuntimeConfig.java @@ -3,46 +3,57 @@ import java.util.Optional; import io.quarkus.runtime.annotations.ConfigGroup; -import io.quarkus.runtime.annotations.ConfigItem; -@SuppressWarnings("OptionalUsedAsFieldOrParameterType") @ConfigGroup -public class ArtemisRuntimeConfig { +public interface ArtemisRuntimeConfig { /** - * Artemis connection url + * Artemis connection url. */ - @ConfigItem - public Optional url = Optional.empty(); + Optional url(); /** - * Username for authentication, only used with JMS + * Username for authentication, only used with JMS. */ - @ConfigItem - public Optional username = Optional.empty(); + Optional username(); /** - * Password for authentication, only used with JMS + * Password for authentication, only used with JMS. */ - @ConfigItem - public Optional password = Optional.empty(); + Optional password(); - public String getUrl() { - return url.orElse(null); + /** + * Whether this particular data source should be excluded from the health check if + * the general health check for data sources is enabled. + *

+ * By default, the health check includes all configured data sources (if it is enabled). + */ + Optional healthExclude(); + + default String getUrl() { + return url().orElse(null); + } + + default String getUsername() { + return username().orElse(null); + } + + default String getPassword() { + return password().orElse(null); } - public String getUsername() { - return username.orElse(null); + default boolean isHealthExclude() { + return healthExclude().orElse(false); } - public String getPassword() { - return password.orElse(null); + default boolean isHealthInclude() { + return !isHealthExclude(); } - public boolean isEmpty() { - return url.isEmpty() && username.isEmpty() && password.isEmpty(); + default boolean isEmpty() { + return url().isEmpty() && username().isEmpty() && password().isEmpty() && healthExclude().isEmpty(); } - public boolean isPresent() { + default boolean isPresent() { return !isEmpty(); } } diff --git a/core/runtime/src/main/java/io/quarkus/artemis/core/runtime/ArtemisRuntimeConfigs.java b/core/runtime/src/main/java/io/quarkus/artemis/core/runtime/ArtemisRuntimeConfigs.java index 625d2147..437ec8a5 100644 --- a/core/runtime/src/main/java/io/quarkus/artemis/core/runtime/ArtemisRuntimeConfigs.java +++ b/core/runtime/src/main/java/io/quarkus/artemis/core/runtime/ArtemisRuntimeConfigs.java @@ -1,65 +1,59 @@ package io.quarkus.artemis.core.runtime; -import java.util.HashMap; +import java.util.HashSet; import java.util.Map; import java.util.Optional; +import java.util.Set; import io.quarkus.runtime.annotations.ConfigDocMapKey; import io.quarkus.runtime.annotations.ConfigDocSection; -import io.quarkus.runtime.annotations.ConfigGroup; -import io.quarkus.runtime.annotations.ConfigItem; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; - -@SuppressWarnings("OptionalUsedAsFieldOrParameterType") -@ConfigGroup -@ConfigRoot(name = "artemis", phase = ConfigPhase.RUN_TIME) -public class ArtemisRuntimeConfigs { - /** - * The default configuration - */ - @ConfigItem(name = ConfigItem.PARENT) - public ArtemisRuntimeConfig defaultConfig; - +import io.smallrye.config.ConfigMapping; +import io.smallrye.config.WithDefaults; +import io.smallrye.config.WithName; +import io.smallrye.config.WithParentName; +import io.smallrye.config.WithUnnamedKey; + +@ConfigMapping(prefix = "quarkus.artemis") +@ConfigRoot(phase = ConfigPhase.RUN_TIME) +public interface ArtemisRuntimeConfigs { /** - * Additional named configuration + * Configurations */ @ConfigDocSection @ConfigDocMapKey("configuration-name") - @ConfigItem(name = ConfigItem.PARENT) - public Map namedConfigs = new HashMap<>(); + @WithParentName + @WithDefaults + @WithUnnamedKey(ArtemisUtil.DEFAULT_CONFIG_NAME) + Map configs(); /** * Whether configurations ({@link org.apache.activemq.artemis.api.core.client.ServerLocator}s in case of the * {@code artemis-core} extension, {@link jakarta.jms.ConnectionFactory}s in case of the * {@code artemis-jms} extension) should be included in the health check. Defaults to {@code true} if not set. */ - @ConfigItem(name = "health.external.enabled") - public Optional healthExternalEnabled = Optional.empty(); - - public ArtemisRuntimeConfig getDefaultConfig() { - return defaultConfig; - } - - private Map getNamedConfigs() { - return namedConfigs; - } - - public boolean getHealthExternalEnabled() { - return healthExternalEnabled.orElse(true); + @WithName("health.external.enabled") + Optional healthExternalEnabled(); + + default Set getNames() { + HashSet names = new HashSet<>(); + for (var entry : configs().entrySet()) { + if (entry.getValue().isPresent()) { + names.add(entry.getKey()); + } + } + return names; } - public Map getAllConfigs() { - HashMap allConfigs = new HashMap<>(getNamedConfigs()); - if (getDefaultConfig() != null && !getDefaultConfig().isEmpty()) { - allConfigs.put(ArtemisUtil.DEFAULT_CONFIG_NAME, getDefaultConfig()); - } - return allConfigs; + default boolean getHealthExternalEnabled() { + return healthExternalEnabled().orElse(true); } - public boolean isEmpty() { - return defaultConfig.isEmpty() - && namedConfigs.isEmpty() - && healthExternalEnabled.isEmpty(); + default boolean isEmpty() { + Boolean hasNoConfig = configs().values().stream() + .map(ArtemisRuntimeConfig::isEmpty) + .reduce(true, Boolean::logicalAnd); + return hasNoConfig && healthExternalEnabled().isEmpty(); } } diff --git a/core/runtime/src/main/java/io/quarkus/artemis/core/runtime/health/ServerLocatorHealthCheck.java b/core/runtime/src/main/java/io/quarkus/artemis/core/runtime/health/ServerLocatorHealthCheck.java index eeec2b32..46365ab5 100644 --- a/core/runtime/src/main/java/io/quarkus/artemis/core/runtime/health/ServerLocatorHealthCheck.java +++ b/core/runtime/src/main/java/io/quarkus/artemis/core/runtime/health/ServerLocatorHealthCheck.java @@ -16,6 +16,7 @@ import org.eclipse.microprofile.health.Readiness; import io.quarkus.arc.Arc; +import io.quarkus.arc.InstanceHandle; import io.quarkus.artemis.core.runtime.ArtemisBuildTimeConfigs; import io.quarkus.artemis.core.runtime.ArtemisRuntimeConfigs; import io.quarkus.artemis.core.runtime.ArtemisUtil; @@ -27,8 +28,8 @@ public class ServerLocatorHealthCheck implements HealthCheck { private final HashMap serverLocators = new HashMap<>(); public ServerLocatorHealthCheck( - @SuppressWarnings("CdiInjectionPointsInspection") ArtemisRuntimeConfigs runtimeConfigs, - @SuppressWarnings("CdiInjectionPointsInspection") ArtemisBuildTimeConfigs buildTimeConfigs, + ArtemisRuntimeConfigs runtimeConfigs, + ArtemisBuildTimeConfigs buildTimeConfigs, @SuppressWarnings("CdiInjectionPointsInspection") ArtemisHealthSupport support) { HashSet includedNames = new HashSet<>(support.getConfiguredNames()); includedNames.removeAll(support.getExcludedNames()); @@ -38,14 +39,17 @@ public ServerLocatorHealthCheck( private void processKnownBeans(ArtemisRuntimeConfigs runtimeConfigs, HashSet includedNames) { for (String name : includedNames) { - if (runtimeConfigs.getAllConfigs().get(name) != null) { + if (runtimeConfigs.configs().get(name).isHealthInclude()) { Annotation identifier; if (ArtemisUtil.isDefault(name)) { identifier = Default.Literal.INSTANCE; } else { identifier = Identifier.Literal.of(name); } - ServerLocator locator = Arc.container().instance(ServerLocator.class, identifier).get(); + ServerLocator locator; + try (InstanceHandle handle = Arc.container().instance(ServerLocator.class, identifier)) { + locator = handle.get(); + } if (locator != null) { serverLocators.put(name, locator); } @@ -55,8 +59,8 @@ private void processKnownBeans(ArtemisRuntimeConfigs runtimeConfigs, HashSet namesToIgnore = new HashSet<>(runtimeConfigs.getAllConfigs().keySet()); - namesToIgnore.addAll(buildTimeConfigs.getAllConfigs().keySet()); + HashSet namesToIgnore = new HashSet<>(runtimeConfigs.configs().keySet()); + namesToIgnore.addAll(buildTimeConfigs.configs().keySet()); Map locatorNamesFromArc = ArtemisUtil.extractIdentifiers(ServerLocator.class, namesToIgnore); for (var entry : locatorNamesFromArc.entrySet()) { ServerLocator locator = entry.getValue(); diff --git a/docs/modules/ROOT/pages/includes/attributes.adoc b/docs/modules/ROOT/pages/includes/attributes.adoc index cfd2cb43..f25a10e4 100644 --- a/docs/modules/ROOT/pages/includes/attributes.adoc +++ b/docs/modules/ROOT/pages/includes/attributes.adoc @@ -1,4 +1,4 @@ -:quarkus-version: 3.4.2 +:quarkus-version: 3.4.3 :quarkus-artemis-version: 3.1.2 :quarkus-org-url: https://github.com/quarkusio diff --git a/docs/modules/ROOT/pages/includes/quarkus-artemis-core.adoc b/docs/modules/ROOT/pages/includes/quarkus-artemis-core.adoc index 710b3e16..87cbc9af 100644 --- a/docs/modules/ROOT/pages/includes/quarkus-artemis-core.adoc +++ b/docs/modules/ROOT/pages/includes/quarkus-artemis-core.adoc @@ -10,8 +10,51 @@ h|[[quarkus-artemis-core_configuration]]link:#quarkus-artemis-core_configuration h|Type h|Default +a|icon:lock[title=Fixed at build time] [[quarkus-artemis-core_quarkus.artemis.health.enabled]]`link:#quarkus-artemis-core_quarkus.artemis.health.enabled[quarkus.artemis.health.enabled]` + + +[.description] +-- +Whether a health check is published in case the smallrye-health extension is present. + +This is a global setting and is not specific to a datasource. + +ifdef::add-copy-button-to-env-var[] +Environment variable: env_var_with_copy_button:+++QUARKUS_ARTEMIS_HEALTH_ENABLED+++[] +endif::add-copy-button-to-env-var[] +ifndef::add-copy-button-to-env-var[] +Environment variable: `+++QUARKUS_ARTEMIS_HEALTH_ENABLED+++` +endif::add-copy-button-to-env-var[] +--|boolean +| + + +a| [[quarkus-artemis-core_quarkus.artemis.health.external.enabled]]`link:#quarkus-artemis-core_quarkus.artemis.health.external.enabled[quarkus.artemis.health.external.enabled]` + + +[.description] +-- +Whether configurations (`org.apache.activemq.artemis.api.core.client.ServerLocator`s in case of the `artemis-core` extension, `jakarta.jms.ConnectionFactory`s in case of the `artemis-jms` extension) should be included in the health check. Defaults to `true` if not set. + +ifdef::add-copy-button-to-env-var[] +Environment variable: env_var_with_copy_button:+++QUARKUS_ARTEMIS_HEALTH_EXTERNAL_ENABLED+++[] +endif::add-copy-button-to-env-var[] +ifndef::add-copy-button-to-env-var[] +Environment variable: `+++QUARKUS_ARTEMIS_HEALTH_EXTERNAL_ENABLED+++` +endif::add-copy-button-to-env-var[] +--|boolean +| + + +h|[[quarkus-artemis-core_quarkus.artemis.configs-configurations]]link:#quarkus-artemis-core_quarkus.artemis.configs-configurations[Configurations] + +h|Type +h|Default + a|icon:lock[title=Fixed at build time] [[quarkus-artemis-core_quarkus.artemis.enabled]]`link:#quarkus-artemis-core_quarkus.artemis.enabled[quarkus.artemis.enabled]` +`link:#quarkus-artemis-core_quarkus.artemis.enabled[quarkus.artemis."configuration-name".enabled]` + [.description] -- @@ -31,6 +74,8 @@ endif::add-copy-button-to-env-var[] a|icon:lock[title=Fixed at build time] [[quarkus-artemis-core_quarkus.artemis.devservices.enabled]]`link:#quarkus-artemis-core_quarkus.artemis.devservices.enabled[quarkus.artemis.devservices.enabled]` +`link:#quarkus-artemis-core_quarkus.artemis.devservices.enabled[quarkus.artemis."configuration-name".devservices.enabled]` + [.description] -- @@ -48,6 +93,8 @@ endif::add-copy-button-to-env-var[] a|icon:lock[title=Fixed at build time] [[quarkus-artemis-core_quarkus.artemis.devservices.port]]`link:#quarkus-artemis-core_quarkus.artemis.devservices.port[quarkus.artemis.devservices.port]` +`link:#quarkus-artemis-core_quarkus.artemis.devservices.port[quarkus.artemis."configuration-name".devservices.port]` + [.description] -- @@ -67,6 +114,8 @@ endif::add-copy-button-to-env-var[] a|icon:lock[title=Fixed at build time] [[quarkus-artemis-core_quarkus.artemis.devservices.image-name]]`link:#quarkus-artemis-core_quarkus.artemis.devservices.image-name[quarkus.artemis.devservices.image-name]` +`link:#quarkus-artemis-core_quarkus.artemis.devservices.image-name[quarkus.artemis."configuration-name".devservices.image-name]` + [.description] -- @@ -86,6 +135,8 @@ endif::add-copy-button-to-env-var[] a|icon:lock[title=Fixed at build time] [[quarkus-artemis-core_quarkus.artemis.devservices.shared]]`link:#quarkus-artemis-core_quarkus.artemis.devservices.shared[quarkus.artemis.devservices.shared]` +`link:#quarkus-artemis-core_quarkus.artemis.devservices.shared[quarkus.artemis."configuration-name".devservices.shared]` + [.description] -- @@ -107,6 +158,8 @@ endif::add-copy-button-to-env-var[] a|icon:lock[title=Fixed at build time] [[quarkus-artemis-core_quarkus.artemis.devservices.service-name]]`link:#quarkus-artemis-core_quarkus.artemis.devservices.service-name[quarkus.artemis.devservices.service-name]` +`link:#quarkus-artemis-core_quarkus.artemis.devservices.service-name[quarkus.artemis."configuration-name".devservices.service-name]` + [.description] -- @@ -126,6 +179,8 @@ endif::add-copy-button-to-env-var[] a|icon:lock[title=Fixed at build time] [[quarkus-artemis-core_quarkus.artemis.devservices.user]]`link:#quarkus-artemis-core_quarkus.artemis.devservices.user[quarkus.artemis.devservices.user]` +`link:#quarkus-artemis-core_quarkus.artemis.devservices.user[quarkus.artemis."configuration-name".devservices.user]` + [.description] -- @@ -143,6 +198,8 @@ endif::add-copy-button-to-env-var[] a|icon:lock[title=Fixed at build time] [[quarkus-artemis-core_quarkus.artemis.devservices.password]]`link:#quarkus-artemis-core_quarkus.artemis.devservices.password[quarkus.artemis.devservices.password]` +`link:#quarkus-artemis-core_quarkus.artemis.devservices.password[quarkus.artemis."configuration-name".devservices.password]` + [.description] -- @@ -160,6 +217,8 @@ endif::add-copy-button-to-env-var[] a|icon:lock[title=Fixed at build time] [[quarkus-artemis-core_quarkus.artemis.devservices.extra-args]]`link:#quarkus-artemis-core_quarkus.artemis.devservices.extra-args[quarkus.artemis.devservices.extra-args]` +`link:#quarkus-artemis-core_quarkus.artemis.devservices.extra-args[quarkus.artemis."configuration-name".devservices.extra-args]` + [.description] -- @@ -175,27 +234,10 @@ endif::add-copy-button-to-env-var[] | -a|icon:lock[title=Fixed at build time] [[quarkus-artemis-core_quarkus.artemis.health-exclude]]`link:#quarkus-artemis-core_quarkus.artemis.health-exclude[quarkus.artemis.health-exclude]` - - -[.description] --- -Whether this particular data source should be excluded from the health check if the general health check for data sources is enabled. - -By default, the health check includes all configured data sources (if it is enabled). - -ifdef::add-copy-button-to-env-var[] -Environment variable: env_var_with_copy_button:+++QUARKUS_ARTEMIS_HEALTH_EXCLUDE+++[] -endif::add-copy-button-to-env-var[] -ifndef::add-copy-button-to-env-var[] -Environment variable: `+++QUARKUS_ARTEMIS_HEALTH_EXCLUDE+++` -endif::add-copy-button-to-env-var[] ---|boolean -| - - a|icon:lock[title=Fixed at build time] [[quarkus-artemis-core_quarkus.artemis.xa-enabled]]`link:#quarkus-artemis-core_quarkus.artemis.xa-enabled[quarkus.artemis.xa-enabled]` +`link:#quarkus-artemis-core_quarkus.artemis.xa-enabled[quarkus.artemis."configuration-name".xa-enabled]` + [.description] -- @@ -211,31 +253,14 @@ endif::add-copy-button-to-env-var[] | -a|icon:lock[title=Fixed at build time] [[quarkus-artemis-core_quarkus.artemis.health.enabled]]`link:#quarkus-artemis-core_quarkus.artemis.health.enabled[quarkus.artemis.health.enabled]` - - -[.description] --- -Whether a health check is published in case the smallrye-health extension is present. - -This is a global setting and is not specific to a datasource. - -ifdef::add-copy-button-to-env-var[] -Environment variable: env_var_with_copy_button:+++QUARKUS_ARTEMIS_HEALTH_ENABLED+++[] -endif::add-copy-button-to-env-var[] -ifndef::add-copy-button-to-env-var[] -Environment variable: `+++QUARKUS_ARTEMIS_HEALTH_ENABLED+++` -endif::add-copy-button-to-env-var[] ---|boolean -| - - a| [[quarkus-artemis-core_quarkus.artemis.url]]`link:#quarkus-artemis-core_quarkus.artemis.url[quarkus.artemis.url]` +`link:#quarkus-artemis-core_quarkus.artemis.url[quarkus.artemis."configuration-name".url]` + [.description] -- -Artemis connection url +Artemis connection url. ifdef::add-copy-button-to-env-var[] Environment variable: env_var_with_copy_button:+++QUARKUS_ARTEMIS_URL+++[] @@ -249,10 +274,12 @@ endif::add-copy-button-to-env-var[] a| [[quarkus-artemis-core_quarkus.artemis.username]]`link:#quarkus-artemis-core_quarkus.artemis.username[quarkus.artemis.username]` +`link:#quarkus-artemis-core_quarkus.artemis.username[quarkus.artemis."configuration-name".username]` + [.description] -- -Username for authentication, only used with JMS +Username for authentication, only used with JMS. ifdef::add-copy-button-to-env-var[] Environment variable: env_var_with_copy_button:+++QUARKUS_ARTEMIS_USERNAME+++[] @@ -266,10 +293,12 @@ endif::add-copy-button-to-env-var[] a| [[quarkus-artemis-core_quarkus.artemis.password]]`link:#quarkus-artemis-core_quarkus.artemis.password[quarkus.artemis.password]` +`link:#quarkus-artemis-core_quarkus.artemis.password[quarkus.artemis."configuration-name".password]` + [.description] -- -Password for authentication, only used with JMS +Password for authentication, only used with JMS. ifdef::add-copy-button-to-env-var[] Environment variable: env_var_with_copy_button:+++QUARKUS_ARTEMIS_PASSWORD+++[] @@ -281,194 +310,9 @@ endif::add-copy-button-to-env-var[] | -a| [[quarkus-artemis-core_quarkus.artemis.health.external.enabled]]`link:#quarkus-artemis-core_quarkus.artemis.health.external.enabled[quarkus.artemis.health.external.enabled]` +a| [[quarkus-artemis-core_quarkus.artemis.health-exclude]]`link:#quarkus-artemis-core_quarkus.artemis.health-exclude[quarkus.artemis.health-exclude]` - -[.description] --- -Whether configurations (`org.apache.activemq.artemis.api.core.client.ServerLocator`s in case of the `artemis-core` extension, `jakarta.jms.ConnectionFactory`s in case of the `artemis-jms` extension) should be included in the health check. Defaults to `true` if not set. - -ifdef::add-copy-button-to-env-var[] -Environment variable: env_var_with_copy_button:+++QUARKUS_ARTEMIS_HEALTH_EXTERNAL_ENABLED+++[] -endif::add-copy-button-to-env-var[] -ifndef::add-copy-button-to-env-var[] -Environment variable: `+++QUARKUS_ARTEMIS_HEALTH_EXTERNAL_ENABLED+++` -endif::add-copy-button-to-env-var[] ---|boolean -| - - -h|[[quarkus-artemis-core_quarkus.artemis.named-configs-additional-named-configs]]link:#quarkus-artemis-core_quarkus.artemis.named-configs-additional-named-configs[Additional named configs] - -h|Type -h|Default - -a|icon:lock[title=Fixed at build time] [[quarkus-artemis-core_quarkus.artemis.-configuration-name-.enabled]]`link:#quarkus-artemis-core_quarkus.artemis.-configuration-name-.enabled[quarkus.artemis."configuration-name".enabled]` - - -[.description] --- -Whether to enable this configuration. - -Is enabled by default. - -ifdef::add-copy-button-to-env-var[] -Environment variable: env_var_with_copy_button:+++QUARKUS_ARTEMIS__CONFIGURATION_NAME__ENABLED+++[] -endif::add-copy-button-to-env-var[] -ifndef::add-copy-button-to-env-var[] -Environment variable: `+++QUARKUS_ARTEMIS__CONFIGURATION_NAME__ENABLED+++` -endif::add-copy-button-to-env-var[] ---|boolean -| - - -a|icon:lock[title=Fixed at build time] [[quarkus-artemis-core_quarkus.artemis.-configuration-name-.devservices.enabled]]`link:#quarkus-artemis-core_quarkus.artemis.-configuration-name-.devservices.enabled[quarkus.artemis."configuration-name".devservices.enabled]` - - -[.description] --- -Enable or disable Dev Services explicitly. Dev Services are automatically enabled unless `quarkus.artemis.url` is set. - -ifdef::add-copy-button-to-env-var[] -Environment variable: env_var_with_copy_button:+++QUARKUS_ARTEMIS__CONFIGURATION_NAME__DEVSERVICES_ENABLED+++[] -endif::add-copy-button-to-env-var[] -ifndef::add-copy-button-to-env-var[] -Environment variable: `+++QUARKUS_ARTEMIS__CONFIGURATION_NAME__DEVSERVICES_ENABLED+++` -endif::add-copy-button-to-env-var[] ---|boolean -| - - -a|icon:lock[title=Fixed at build time] [[quarkus-artemis-core_quarkus.artemis.-configuration-name-.devservices.port]]`link:#quarkus-artemis-core_quarkus.artemis.-configuration-name-.devservices.port[quarkus.artemis."configuration-name".devservices.port]` - - -[.description] --- -Optional fixed port the dev service will listen to. - -If not defined, the port will be chosen randomly. - -ifdef::add-copy-button-to-env-var[] -Environment variable: env_var_with_copy_button:+++QUARKUS_ARTEMIS__CONFIGURATION_NAME__DEVSERVICES_PORT+++[] -endif::add-copy-button-to-env-var[] -ifndef::add-copy-button-to-env-var[] -Environment variable: `+++QUARKUS_ARTEMIS__CONFIGURATION_NAME__DEVSERVICES_PORT+++` -endif::add-copy-button-to-env-var[] ---|int -| - - -a|icon:lock[title=Fixed at build time] [[quarkus-artemis-core_quarkus.artemis.-configuration-name-.devservices.image-name]]`link:#quarkus-artemis-core_quarkus.artemis.-configuration-name-.devservices.image-name[quarkus.artemis."configuration-name".devservices.image-name]` - - -[.description] --- -The ActiveMQ Artemis container image to use. - -Defaults to `quay.io/artemiscloud/activemq-artemis-broker:artemis.2.31.0` - -ifdef::add-copy-button-to-env-var[] -Environment variable: env_var_with_copy_button:+++QUARKUS_ARTEMIS__CONFIGURATION_NAME__DEVSERVICES_IMAGE_NAME+++[] -endif::add-copy-button-to-env-var[] -ifndef::add-copy-button-to-env-var[] -Environment variable: `+++QUARKUS_ARTEMIS__CONFIGURATION_NAME__DEVSERVICES_IMAGE_NAME+++` -endif::add-copy-button-to-env-var[] ---|string -| - - -a|icon:lock[title=Fixed at build time] [[quarkus-artemis-core_quarkus.artemis.-configuration-name-.devservices.shared]]`link:#quarkus-artemis-core_quarkus.artemis.-configuration-name-.devservices.shared[quarkus.artemis."configuration-name".devservices.shared]` - - -[.description] --- -Indicates if the ActiveMQ Artemis broker managed by Quarkus Dev Services is shared. When shared, Quarkus looks for running containers using label-based service discovery. If a matching container is found, it is used, and so a second one is not started. Otherwise, Dev Services for ActiveMQ Artemis starts a new container. Is activated by default when not set. - -The discovery uses the `quarkus-dev-service-artemis` label. The value is configured using the `service-name` property. - -Container sharing is only used in dev mode. - -ifdef::add-copy-button-to-env-var[] -Environment variable: env_var_with_copy_button:+++QUARKUS_ARTEMIS__CONFIGURATION_NAME__DEVSERVICES_SHARED+++[] -endif::add-copy-button-to-env-var[] -ifndef::add-copy-button-to-env-var[] -Environment variable: `+++QUARKUS_ARTEMIS__CONFIGURATION_NAME__DEVSERVICES_SHARED+++` -endif::add-copy-button-to-env-var[] ---|boolean -| - - -a|icon:lock[title=Fixed at build time] [[quarkus-artemis-core_quarkus.artemis.-configuration-name-.devservices.service-name]]`link:#quarkus-artemis-core_quarkus.artemis.-configuration-name-.devservices.service-name[quarkus.artemis."configuration-name".devservices.service-name]` - - -[.description] --- -The value of the `quarkus-dev-service-artemis` label attached to the started container. This property is used when `shared` is set to `true`. It defaults to `artemis` when not set. In this case, before starting a container, Dev Services for ActiveMQ Artemis looks for a container with the `quarkus-dev-service-artemis` label set to the configured value. If found, it will use this container instead of starting a new one. Otherwise it starts a new container with the `quarkus-dev-service-artemis` label set to the specified value. - -This property is used when you need multiple shared ActiveMQ Artemis brokers. - -ifdef::add-copy-button-to-env-var[] -Environment variable: env_var_with_copy_button:+++QUARKUS_ARTEMIS__CONFIGURATION_NAME__DEVSERVICES_SERVICE_NAME+++[] -endif::add-copy-button-to-env-var[] -ifndef::add-copy-button-to-env-var[] -Environment variable: `+++QUARKUS_ARTEMIS__CONFIGURATION_NAME__DEVSERVICES_SERVICE_NAME+++` -endif::add-copy-button-to-env-var[] ---|string -| - - -a|icon:lock[title=Fixed at build time] [[quarkus-artemis-core_quarkus.artemis.-configuration-name-.devservices.user]]`link:#quarkus-artemis-core_quarkus.artemis.-configuration-name-.devservices.user[quarkus.artemis."configuration-name".devservices.user]` - - -[.description] --- -User to start artemis broker. Defaults to `admin` if not set. - -ifdef::add-copy-button-to-env-var[] -Environment variable: env_var_with_copy_button:+++QUARKUS_ARTEMIS__CONFIGURATION_NAME__DEVSERVICES_USER+++[] -endif::add-copy-button-to-env-var[] -ifndef::add-copy-button-to-env-var[] -Environment variable: `+++QUARKUS_ARTEMIS__CONFIGURATION_NAME__DEVSERVICES_USER+++` -endif::add-copy-button-to-env-var[] ---|string -| - - -a|icon:lock[title=Fixed at build time] [[quarkus-artemis-core_quarkus.artemis.-configuration-name-.devservices.password]]`link:#quarkus-artemis-core_quarkus.artemis.-configuration-name-.devservices.password[quarkus.artemis."configuration-name".devservices.password]` - - -[.description] --- -Password to start artemis broker. Defaults to `admin` whne not set. - -ifdef::add-copy-button-to-env-var[] -Environment variable: env_var_with_copy_button:+++QUARKUS_ARTEMIS__CONFIGURATION_NAME__DEVSERVICES_PASSWORD+++[] -endif::add-copy-button-to-env-var[] -ifndef::add-copy-button-to-env-var[] -Environment variable: `+++QUARKUS_ARTEMIS__CONFIGURATION_NAME__DEVSERVICES_PASSWORD+++` -endif::add-copy-button-to-env-var[] ---|string -| - - -a|icon:lock[title=Fixed at build time] [[quarkus-artemis-core_quarkus.artemis.-configuration-name-.devservices.extra-args]]`link:#quarkus-artemis-core_quarkus.artemis.-configuration-name-.devservices.extra-args[quarkus.artemis."configuration-name".devservices.extra-args]` - - -[.description] --- -The value of the `AMQ_EXTRA_ARGS` environment variable to pass to the container. Defaults to `--no-autotune --mapped --no-fsync` when not set. - -ifdef::add-copy-button-to-env-var[] -Environment variable: env_var_with_copy_button:+++QUARKUS_ARTEMIS__CONFIGURATION_NAME__DEVSERVICES_EXTRA_ARGS+++[] -endif::add-copy-button-to-env-var[] -ifndef::add-copy-button-to-env-var[] -Environment variable: `+++QUARKUS_ARTEMIS__CONFIGURATION_NAME__DEVSERVICES_EXTRA_ARGS+++` -endif::add-copy-button-to-env-var[] ---|string -| - - -a|icon:lock[title=Fixed at build time] [[quarkus-artemis-core_quarkus.artemis.-configuration-name-.health-exclude]]`link:#quarkus-artemis-core_quarkus.artemis.-configuration-name-.health-exclude[quarkus.artemis."configuration-name".health-exclude]` +`link:#quarkus-artemis-core_quarkus.artemis.health-exclude[quarkus.artemis."configuration-name".health-exclude]` [.description] @@ -478,85 +322,12 @@ Whether this particular data source should be excluded from the health check if By default, the health check includes all configured data sources (if it is enabled). ifdef::add-copy-button-to-env-var[] -Environment variable: env_var_with_copy_button:+++QUARKUS_ARTEMIS__CONFIGURATION_NAME__HEALTH_EXCLUDE+++[] -endif::add-copy-button-to-env-var[] -ifndef::add-copy-button-to-env-var[] -Environment variable: `+++QUARKUS_ARTEMIS__CONFIGURATION_NAME__HEALTH_EXCLUDE+++` -endif::add-copy-button-to-env-var[] ---|boolean -| - - -a|icon:lock[title=Fixed at build time] [[quarkus-artemis-core_quarkus.artemis.-configuration-name-.xa-enabled]]`link:#quarkus-artemis-core_quarkus.artemis.-configuration-name-.xa-enabled[quarkus.artemis."configuration-name".xa-enabled]` - - -[.description] --- -Support to expose `jakarta.jms.XAConnectionFactory`. Is not activated by default. - -ifdef::add-copy-button-to-env-var[] -Environment variable: env_var_with_copy_button:+++QUARKUS_ARTEMIS__CONFIGURATION_NAME__XA_ENABLED+++[] +Environment variable: env_var_with_copy_button:+++QUARKUS_ARTEMIS_HEALTH_EXCLUDE+++[] endif::add-copy-button-to-env-var[] ifndef::add-copy-button-to-env-var[] -Environment variable: `+++QUARKUS_ARTEMIS__CONFIGURATION_NAME__XA_ENABLED+++` +Environment variable: `+++QUARKUS_ARTEMIS_HEALTH_EXCLUDE+++` endif::add-copy-button-to-env-var[] --|boolean | - -h|[[quarkus-artemis-core_quarkus.artemis.named-configs-additional-named-configuration]]link:#quarkus-artemis-core_quarkus.artemis.named-configs-additional-named-configuration[Additional named configuration] - -h|Type -h|Default - -a| [[quarkus-artemis-core_quarkus.artemis.-configuration-name-.url]]`link:#quarkus-artemis-core_quarkus.artemis.-configuration-name-.url[quarkus.artemis."configuration-name".url]` - - -[.description] --- -Artemis connection url - -ifdef::add-copy-button-to-env-var[] -Environment variable: env_var_with_copy_button:+++QUARKUS_ARTEMIS__CONFIGURATION_NAME__URL+++[] -endif::add-copy-button-to-env-var[] -ifndef::add-copy-button-to-env-var[] -Environment variable: `+++QUARKUS_ARTEMIS__CONFIGURATION_NAME__URL+++` -endif::add-copy-button-to-env-var[] ---|string -| - - -a| [[quarkus-artemis-core_quarkus.artemis.-configuration-name-.username]]`link:#quarkus-artemis-core_quarkus.artemis.-configuration-name-.username[quarkus.artemis."configuration-name".username]` - - -[.description] --- -Username for authentication, only used with JMS - -ifdef::add-copy-button-to-env-var[] -Environment variable: env_var_with_copy_button:+++QUARKUS_ARTEMIS__CONFIGURATION_NAME__USERNAME+++[] -endif::add-copy-button-to-env-var[] -ifndef::add-copy-button-to-env-var[] -Environment variable: `+++QUARKUS_ARTEMIS__CONFIGURATION_NAME__USERNAME+++` -endif::add-copy-button-to-env-var[] ---|string -| - - -a| [[quarkus-artemis-core_quarkus.artemis.-configuration-name-.password]]`link:#quarkus-artemis-core_quarkus.artemis.-configuration-name-.password[quarkus.artemis."configuration-name".password]` - - -[.description] --- -Password for authentication, only used with JMS - -ifdef::add-copy-button-to-env-var[] -Environment variable: env_var_with_copy_button:+++QUARKUS_ARTEMIS__CONFIGURATION_NAME__PASSWORD+++[] -endif::add-copy-button-to-env-var[] -ifndef::add-copy-button-to-env-var[] -Environment variable: `+++QUARKUS_ARTEMIS__CONFIGURATION_NAME__PASSWORD+++` -endif::add-copy-button-to-env-var[] ---|string -| - |=== \ No newline at end of file diff --git a/integration-tests/camel-jms/with-default-and-named/src/main/resources/application.properties b/integration-tests/camel-jms/with-default-and-named/src/main/resources/application.properties index 24631638..c24e02f7 100644 --- a/integration-tests/camel-jms/with-default-and-named/src/main/resources/application.properties +++ b/integration-tests/camel-jms/with-default-and-named/src/main/resources/application.properties @@ -1,2 +1,3 @@ quarkus.artemis.devservices.enabled=false -quarkus.artemis."named".devservices.enabled=false \ No newline at end of file +quarkus.artemis."named".devservices.enabled=false +quarkus.artemis."named".health-exclude=true \ No newline at end of file diff --git a/integration-tests/camel-jms/with-default-and-named/src/test/java/io/quarkus/it/artemis/camel/jms/withdefaultandnamed/BaseArtemisHealthCheck.java b/integration-tests/camel-jms/with-default-and-named/src/test/java/io/quarkus/it/artemis/camel/jms/withdefaultandnamed/BaseArtemisHealthCheck.java new file mode 100644 index 00000000..db970db9 --- /dev/null +++ b/integration-tests/camel-jms/with-default-and-named/src/test/java/io/quarkus/it/artemis/camel/jms/withdefaultandnamed/BaseArtemisHealthCheck.java @@ -0,0 +1,26 @@ +package io.quarkus.it.artemis.camel.jms.withdefaultandnamed; + +import java.util.Set; + +import org.junit.jupiter.api.Test; + +import io.quarkus.artemis.test.ArtemisTestResource; +import io.quarkus.it.artemis.camel.jms.withdefaultandnamed.embedded.NamedArtemisTestResource; +import io.quarkus.it.artemis.common.ArtemisHealthCheckHelper; +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +@QuarkusTestResource(ArtemisTestResource.class) +@QuarkusTestResource(NamedArtemisTestResource.class) +public abstract class BaseArtemisHealthCheck { + @Test + void testHealth() { + ArtemisHealthCheckHelper.testJms("/q/health", Set.of("")); + } + + @Test + void testReady() { + ArtemisHealthCheckHelper.testJms("/q/health/ready", Set.of("")); + } +} diff --git a/integration-tests/camel-jms/with-default-and-named/src/test/java/io/quarkus/it/artemis/camel/jms/withdefaultandnamed/devservices/DevServicesHealthCheckTest.java b/integration-tests/camel-jms/with-default-and-named/src/test/java/io/quarkus/it/artemis/camel/jms/withdefaultandnamed/devservices/DevServicesHealthCheckTest.java index 5486e1ac..3d42c53e 100644 --- a/integration-tests/camel-jms/with-default-and-named/src/test/java/io/quarkus/it/artemis/camel/jms/withdefaultandnamed/devservices/DevServicesHealthCheckTest.java +++ b/integration-tests/camel-jms/with-default-and-named/src/test/java/io/quarkus/it/artemis/camel/jms/withdefaultandnamed/devservices/DevServicesHealthCheckTest.java @@ -1,23 +1,10 @@ package io.quarkus.it.artemis.camel.jms.withdefaultandnamed.devservices; -import java.util.Set; - -import org.junit.jupiter.api.Test; - -import io.quarkus.it.artemis.common.ArtemisHealthCheckHelper; +import io.quarkus.it.artemis.camel.jms.withdefaultandnamed.BaseArtemisHealthCheck; import io.quarkus.test.junit.QuarkusTest; import io.quarkus.test.junit.TestProfile; @QuarkusTest @TestProfile(DevservicesArtemisEnabled.class) -class DevServicesHealthCheckTest { - @Test - void testHealth() { - ArtemisHealthCheckHelper.testJms("/q/health", Set.of("", "named")); - } - - @Test - void testReady() { - ArtemisHealthCheckHelper.testJms("/q/health/ready", Set.of("", "named")); - } +class DevServicesHealthCheckTest extends BaseArtemisHealthCheck { } diff --git a/integration-tests/camel-jms/with-default-and-named/src/test/java/io/quarkus/it/artemis/camel/jms/withdefaultandnamed/embedded/EmbeddedHealthCheckTest.java b/integration-tests/camel-jms/with-default-and-named/src/test/java/io/quarkus/it/artemis/camel/jms/withdefaultandnamed/embedded/EmbeddedHealthCheckTest.java index 6ec40f67..e27a07e9 100644 --- a/integration-tests/camel-jms/with-default-and-named/src/test/java/io/quarkus/it/artemis/camel/jms/withdefaultandnamed/embedded/EmbeddedHealthCheckTest.java +++ b/integration-tests/camel-jms/with-default-and-named/src/test/java/io/quarkus/it/artemis/camel/jms/withdefaultandnamed/embedded/EmbeddedHealthCheckTest.java @@ -1,25 +1,12 @@ package io.quarkus.it.artemis.camel.jms.withdefaultandnamed.embedded; -import java.util.Set; - -import org.junit.jupiter.api.Test; - import io.quarkus.artemis.test.ArtemisTestResource; -import io.quarkus.it.artemis.common.ArtemisHealthCheckHelper; +import io.quarkus.it.artemis.camel.jms.withdefaultandnamed.BaseArtemisHealthCheck; import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusTest; @QuarkusTest @QuarkusTestResource(ArtemisTestResource.class) @QuarkusTestResource(NamedArtemisTestResource.class) -class EmbeddedHealthCheckTest { - @Test - void testHealth() { - ArtemisHealthCheckHelper.testJms("/q/health", Set.of("", "named")); - } - - @Test - void testReady() { - ArtemisHealthCheckHelper.testJms("/q/health/ready", Set.of("", "named")); - } +class EmbeddedHealthCheckTest extends BaseArtemisHealthCheck { } diff --git a/integration-tests/camel-jms/with-default/src/test/java/io/quarkus/it/artemis/camel/jms/withdefault/BaseArtemisHealthCheckTest.java b/integration-tests/camel-jms/with-default/src/test/java/io/quarkus/it/artemis/camel/jms/withdefault/BaseArtemisHealthCheckTest.java new file mode 100644 index 00000000..058baf51 --- /dev/null +++ b/integration-tests/camel-jms/with-default/src/test/java/io/quarkus/it/artemis/camel/jms/withdefault/BaseArtemisHealthCheckTest.java @@ -0,0 +1,19 @@ +package io.quarkus.it.artemis.camel.jms.withdefault; + +import java.util.Set; + +import org.junit.jupiter.api.Test; + +import io.quarkus.it.artemis.common.ArtemisHealthCheckHelper; + +public abstract class BaseArtemisHealthCheckTest { + @Test + void testHealth() { + ArtemisHealthCheckHelper.testJms("/q/health", Set.of("")); + } + + @Test + void testReady() { + ArtemisHealthCheckHelper.testJms("/q/health/ready", Set.of("")); + } +} diff --git a/integration-tests/camel-jms/with-default/src/test/java/io/quarkus/it/artemis/camel/jms/withdefault/devservices/DevServicesHealthCheckTest.java b/integration-tests/camel-jms/with-default/src/test/java/io/quarkus/it/artemis/camel/jms/withdefault/devservices/DevServicesHealthCheckTest.java index fab2d4c6..f241c61f 100644 --- a/integration-tests/camel-jms/with-default/src/test/java/io/quarkus/it/artemis/camel/jms/withdefault/devservices/DevServicesHealthCheckTest.java +++ b/integration-tests/camel-jms/with-default/src/test/java/io/quarkus/it/artemis/camel/jms/withdefault/devservices/DevServicesHealthCheckTest.java @@ -1,23 +1,10 @@ package io.quarkus.it.artemis.camel.jms.withdefault.devservices; -import java.util.Set; - -import org.junit.jupiter.api.Test; - -import io.quarkus.it.artemis.common.ArtemisHealthCheckHelper; +import io.quarkus.it.artemis.camel.jms.withdefault.BaseArtemisHealthCheckTest; import io.quarkus.test.junit.QuarkusTest; import io.quarkus.test.junit.TestProfile; @QuarkusTest @TestProfile(DevservicesArtemisEnabled.class) -class DevServicesHealthCheckTest { - @Test - void testHealth() { - ArtemisHealthCheckHelper.testJms("/q/health", Set.of("")); - } - - @Test - void testReady() { - ArtemisHealthCheckHelper.testJms("/q/health/ready", Set.of("")); - } +class DevServicesHealthCheckTest extends BaseArtemisHealthCheckTest { } diff --git a/integration-tests/camel-jms/with-default/src/test/java/io/quarkus/it/artemis/camel/jms/withdefault/embedded/EmbeddedHealthCheckTest.java b/integration-tests/camel-jms/with-default/src/test/java/io/quarkus/it/artemis/camel/jms/withdefault/embedded/EmbeddedHealthCheckTest.java index 95b247b7..21a2581c 100644 --- a/integration-tests/camel-jms/with-default/src/test/java/io/quarkus/it/artemis/camel/jms/withdefault/embedded/EmbeddedHealthCheckTest.java +++ b/integration-tests/camel-jms/with-default/src/test/java/io/quarkus/it/artemis/camel/jms/withdefault/embedded/EmbeddedHealthCheckTest.java @@ -1,24 +1,11 @@ package io.quarkus.it.artemis.camel.jms.withdefault.embedded; -import java.util.Set; - -import org.junit.jupiter.api.Test; - import io.quarkus.artemis.test.ArtemisTestResource; -import io.quarkus.it.artemis.common.ArtemisHealthCheckHelper; +import io.quarkus.it.artemis.camel.jms.withdefault.BaseArtemisHealthCheckTest; import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusTest; @QuarkusTest @QuarkusTestResource(ArtemisTestResource.class) -class EmbeddedHealthCheckTest { - @Test - void testHealth() { - ArtemisHealthCheckHelper.testJms("/q/health", Set.of("")); - } - - @Test - void testReady() { - ArtemisHealthCheckHelper.testJms("/q/health/ready", Set.of("")); - } +class EmbeddedHealthCheckTest extends BaseArtemisHealthCheckTest { } diff --git a/integration-tests/camel-jms/with-named/src/test/java/io/quarkus/it/artemis/camel/jms/withnamed/BaseArtemisHealthCheckTest.java b/integration-tests/camel-jms/with-named/src/test/java/io/quarkus/it/artemis/camel/jms/withnamed/BaseArtemisHealthCheckTest.java new file mode 100644 index 00000000..4ccd6536 --- /dev/null +++ b/integration-tests/camel-jms/with-named/src/test/java/io/quarkus/it/artemis/camel/jms/withnamed/BaseArtemisHealthCheckTest.java @@ -0,0 +1,19 @@ +package io.quarkus.it.artemis.camel.jms.withnamed; + +import java.util.Set; + +import org.junit.jupiter.api.Test; + +import io.quarkus.it.artemis.common.ArtemisHealthCheckHelper; + +public abstract class BaseArtemisHealthCheckTest { + @Test + void testHealth() { + ArtemisHealthCheckHelper.testJms("/q/health", Set.of("named")); + } + + @Test + void testReady() { + ArtemisHealthCheckHelper.testJms("/q/health/ready", Set.of("named")); + } +} diff --git a/integration-tests/camel-jms/with-named/src/test/java/io/quarkus/it/artemis/camel/jms/withnamed/devservices/DevServicesHealthCheckTest.java b/integration-tests/camel-jms/with-named/src/test/java/io/quarkus/it/artemis/camel/jms/withnamed/devservices/DevServicesHealthCheckTest.java index b62f81ab..953e12b5 100644 --- a/integration-tests/camel-jms/with-named/src/test/java/io/quarkus/it/artemis/camel/jms/withnamed/devservices/DevServicesHealthCheckTest.java +++ b/integration-tests/camel-jms/with-named/src/test/java/io/quarkus/it/artemis/camel/jms/withnamed/devservices/DevServicesHealthCheckTest.java @@ -1,23 +1,10 @@ package io.quarkus.it.artemis.camel.jms.withnamed.devservices; -import java.util.Set; - -import org.junit.jupiter.api.Test; - -import io.quarkus.it.artemis.common.ArtemisHealthCheckHelper; +import io.quarkus.it.artemis.camel.jms.withnamed.BaseArtemisHealthCheckTest; import io.quarkus.test.junit.QuarkusTest; import io.quarkus.test.junit.TestProfile; @QuarkusTest @TestProfile(DevservicesArtemisEnabled.class) -class DevServicesHealthCheckTest { - @Test - void testHealth() { - ArtemisHealthCheckHelper.testJms("/q/health", Set.of("named")); - } - - @Test - void testReady() { - ArtemisHealthCheckHelper.testJms("/q/health/ready", Set.of("named")); - } +class DevServicesHealthCheckTest extends BaseArtemisHealthCheckTest { } diff --git a/integration-tests/camel-jms/with-named/src/test/java/io/quarkus/it/artemis/camel/jms/withnamed/embedded/EmbeddedHealthCheckTest.java b/integration-tests/camel-jms/with-named/src/test/java/io/quarkus/it/artemis/camel/jms/withnamed/embedded/EmbeddedHealthCheckTest.java index 6a734329..032c35f2 100644 --- a/integration-tests/camel-jms/with-named/src/test/java/io/quarkus/it/artemis/camel/jms/withnamed/embedded/EmbeddedHealthCheckTest.java +++ b/integration-tests/camel-jms/with-named/src/test/java/io/quarkus/it/artemis/camel/jms/withnamed/embedded/EmbeddedHealthCheckTest.java @@ -1,23 +1,10 @@ package io.quarkus.it.artemis.camel.jms.withnamed.embedded; -import java.util.Set; - -import org.junit.jupiter.api.Test; - -import io.quarkus.it.artemis.common.ArtemisHealthCheckHelper; +import io.quarkus.it.artemis.camel.jms.withnamed.BaseArtemisHealthCheckTest; import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusTest; @QuarkusTest @QuarkusTestResource(NamedArtemisTestResource.class) -class EmbeddedHealthCheckTest { - @Test - void testHealth() { - ArtemisHealthCheckHelper.testJms("/q/health", Set.of("named")); - } - - @Test - void testReady() { - ArtemisHealthCheckHelper.testJms("/q/health/ready", Set.of("named")); - } +class EmbeddedHealthCheckTest extends BaseArtemisHealthCheckTest { } diff --git a/integration-tests/core/with-default/src/main/resources/application.properties b/integration-tests/core/with-default/src/main/resources/application.properties index d74730bf..f80286ae 100644 --- a/integration-tests/core/with-default/src/main/resources/application.properties +++ b/integration-tests/core/with-default/src/main/resources/application.properties @@ -1,3 +1,4 @@ quarkus.artemis.devservices.enabled=false +quarkus.artemis.health-exclude=true quarkus.artemis."named-1".devservices.enabled=false quarkus.artemis."named-2".enabled=false diff --git a/integration-tests/core/with-default/src/test/java/io/quarkus/it/artemis/core/withdefault/BaseArtemisHealthCheckTest.java b/integration-tests/core/with-default/src/test/java/io/quarkus/it/artemis/core/withdefault/BaseArtemisHealthCheckTest.java index 21ff2cb2..643fd5ec 100644 --- a/integration-tests/core/with-default/src/test/java/io/quarkus/it/artemis/core/withdefault/BaseArtemisHealthCheckTest.java +++ b/integration-tests/core/with-default/src/test/java/io/quarkus/it/artemis/core/withdefault/BaseArtemisHealthCheckTest.java @@ -9,11 +9,11 @@ public abstract class BaseArtemisHealthCheckTest { @Test void testHealth() { - ArtemisHealthCheckHelper.testCore("/q/health", Set.of("", "named-1")); + ArtemisHealthCheckHelper.testCore("/q/health", Set.of("named-1")); } @Test void testReady() { - ArtemisHealthCheckHelper.testCore("/q/health/ready", Set.of("", "named-1")); + ArtemisHealthCheckHelper.testCore("/q/health/ready", Set.of("named-1")); } } diff --git a/integration-tests/jms/with-default/src/main/resources/application.properties b/integration-tests/jms/with-default/src/main/resources/application.properties index e3fbeaee..72d6b6da 100644 --- a/integration-tests/jms/with-default/src/main/resources/application.properties +++ b/integration-tests/jms/with-default/src/main/resources/application.properties @@ -1,4 +1,5 @@ quarkus.artemis.devservices.enabled=false +quarkus.artemis.health-exclude=true quarkus.artemis.xa-enabled=true quarkus.artemis."named-1".devservices.enabled=false quarkus.artemis."named-1".xa-enabled=true diff --git a/integration-tests/jms/with-default/src/test/java/io/quarkus/it/artemis/jms/withdefault/BaseArtemisHealthCheckTest.java b/integration-tests/jms/with-default/src/test/java/io/quarkus/it/artemis/jms/withdefault/BaseArtemisHealthCheckTest.java index a23ccb4c..3c0c4141 100644 --- a/integration-tests/jms/with-default/src/test/java/io/quarkus/it/artemis/jms/withdefault/BaseArtemisHealthCheckTest.java +++ b/integration-tests/jms/with-default/src/test/java/io/quarkus/it/artemis/jms/withdefault/BaseArtemisHealthCheckTest.java @@ -9,11 +9,11 @@ public abstract class BaseArtemisHealthCheckTest { @Test void testHealth() { - ArtemisHealthCheckHelper.testJms("/q/health", Set.of("", "named-1")); + ArtemisHealthCheckHelper.testJms("/q/health", Set.of("named-1")); } @Test void testReady() { - ArtemisHealthCheckHelper.testJms("/q/health/ready", Set.of("", "named-1")); + ArtemisHealthCheckHelper.testJms("/q/health/ready", Set.of("named-1")); } } diff --git a/jms/deployment/src/main/java/io/quarkus/artemis/jms/deployment/ArtemisJmsProcessor.java b/jms/deployment/src/main/java/io/quarkus/artemis/jms/deployment/ArtemisJmsProcessor.java index 916c9b09..691fda4f 100644 --- a/jms/deployment/src/main/java/io/quarkus/artemis/jms/deployment/ArtemisJmsProcessor.java +++ b/jms/deployment/src/main/java/io/quarkus/artemis/jms/deployment/ArtemisJmsProcessor.java @@ -15,8 +15,7 @@ import io.quarkus.artemis.core.deployment.ArtemisBootstrappedBuildItem; import io.quarkus.artemis.core.deployment.ArtemisCoreProcessor; import io.quarkus.artemis.core.deployment.ArtemisJmsBuildItem; -import io.quarkus.artemis.core.deployment.ShadowRunTimeConfigs; -import io.quarkus.artemis.core.runtime.ArtemisBuildTimeConfig; +import io.quarkus.artemis.core.deployment.ShadowRuntimeConfigs; import io.quarkus.artemis.core.runtime.ArtemisBuildTimeConfigs; import io.quarkus.artemis.core.runtime.ArtemisRuntimeConfigs; import io.quarkus.artemis.jms.runtime.ArtemisJmsRecorder; @@ -50,7 +49,7 @@ void load(BuildProducer artemisJms) { ArtemisJmsConfiguredBuildItem configure( ArtemisJmsRecorder recorder, ArtemisRuntimeConfigs runtimeConfigs, - ShadowRunTimeConfigs shadowRunTimeConfigs, + ShadowRuntimeConfigs shadowRunTimeConfigs, ArtemisBuildTimeConfigs buildTimeConfigs, ArtemisBootstrappedBuildItem bootstrap, Optional wrapperItem, @@ -63,8 +62,7 @@ ArtemisJmsConfiguredBuildItem configure( Set configurationNames = bootstrap.getConfigurationNames(); boolean isSoleConnectionFactory = configurationNames.size() == 1; for (String name : configurationNames) { - if (!shadowRunTimeConfigs.getNames().contains(name) && buildTimeConfigs.getAllConfigs().getOrDefault(name, - new ArtemisBuildTimeConfig()).isEmpty()) { + if (!shadowRunTimeConfigs.getNames().contains(name) && buildTimeConfigs.configs().get(name).isEmpty()) { continue; } Supplier connectionFactorySupplier = recorder.getConnectionFactoryProducer( @@ -76,8 +74,7 @@ ArtemisJmsConfiguredBuildItem configure( connectionFactorySupplier, name, isSoleConnectionFactory, - buildTimeConfigs.getAllConfigs().getOrDefault(name, - new ArtemisBuildTimeConfig()).isXaEnabled())); + buildTimeConfigs.configs().get(name).isXaEnabled())); } return new ArtemisJmsConfiguredBuildItem(); } diff --git a/jms/runtime/src/main/java/io/quarkus/artemis/jms/runtime/ArtemisJmsRecorder.java b/jms/runtime/src/main/java/io/quarkus/artemis/jms/runtime/ArtemisJmsRecorder.java index 6e77b213..6db773a2 100644 --- a/jms/runtime/src/main/java/io/quarkus/artemis/jms/runtime/ArtemisJmsRecorder.java +++ b/jms/runtime/src/main/java/io/quarkus/artemis/jms/runtime/ArtemisJmsRecorder.java @@ -27,9 +27,8 @@ public Supplier getConnectionFactoryProducer( ArtemisRuntimeConfigs runtimeConfigs, ArtemisBuildTimeConfigs buildTimeConfigs, Function wrapper) { - ArtemisRuntimeConfig runtimeConfig = runtimeConfigs.getAllConfigs().getOrDefault(name, new ArtemisRuntimeConfig()); - ArtemisBuildTimeConfig buildTimeConfig = buildTimeConfigs.getAllConfigs().getOrDefault(name, - new ArtemisBuildTimeConfig()); + ArtemisRuntimeConfig runtimeConfig = runtimeConfigs.configs().get(name); + ArtemisBuildTimeConfig buildTimeConfig = buildTimeConfigs.configs().get(name); ArtemisUtil.validateIntegrity(name, runtimeConfig, buildTimeConfig); final ConnectionFactory connectionFactory = Objects.requireNonNull(extractConnectionFactory(runtimeConfig, wrapper)); return () -> connectionFactory; diff --git a/jms/runtime/src/main/java/io/quarkus/artemis/jms/runtime/health/ConnectionFactoryHealthCheck.java b/jms/runtime/src/main/java/io/quarkus/artemis/jms/runtime/health/ConnectionFactoryHealthCheck.java index 64c753e1..353ea2e1 100644 --- a/jms/runtime/src/main/java/io/quarkus/artemis/jms/runtime/health/ConnectionFactoryHealthCheck.java +++ b/jms/runtime/src/main/java/io/quarkus/artemis/jms/runtime/health/ConnectionFactoryHealthCheck.java @@ -16,6 +16,7 @@ import org.eclipse.microprofile.health.Readiness; import io.quarkus.arc.Arc; +import io.quarkus.arc.InstanceHandle; import io.quarkus.artemis.core.runtime.ArtemisBuildTimeConfigs; import io.quarkus.artemis.core.runtime.ArtemisRuntimeConfigs; import io.quarkus.artemis.core.runtime.ArtemisUtil; @@ -28,8 +29,8 @@ public class ConnectionFactoryHealthCheck implements HealthCheck { private final HashMap connectionFactories = new HashMap<>(); public ConnectionFactoryHealthCheck( - @SuppressWarnings("CdiInjectionPointsInspection") ArtemisRuntimeConfigs runtimeConfigs, - @SuppressWarnings("CdiInjectionPointsInspection") ArtemisBuildTimeConfigs buildTimeConfigs, + ArtemisRuntimeConfigs runtimeConfigs, + ArtemisBuildTimeConfigs buildTimeConfigs, @SuppressWarnings("CdiInjectionPointsInspection") ArtemisHealthSupport support) { HashSet includedNames = new HashSet<>(support.getConfiguredNames()); includedNames.removeAll(support.getExcludedNames()); @@ -39,14 +40,17 @@ public ConnectionFactoryHealthCheck( private void processKnownBeans(ArtemisRuntimeConfigs runtimeConfigs, HashSet includedNames) { for (String name : includedNames) { - if (runtimeConfigs.getAllConfigs().get(name) != null) { + if (runtimeConfigs.configs().get(name).isHealthInclude()) { Annotation identifier; if (ArtemisUtil.isDefault(name)) { identifier = Default.Literal.INSTANCE; } else { identifier = Identifier.Literal.of(name); } - ConnectionFactory connectionFactory = Arc.container().instance(ConnectionFactory.class, identifier).get(); + ConnectionFactory connectionFactory; + try (InstanceHandle handle = Arc.container().instance(ConnectionFactory.class, identifier)) { + connectionFactory = handle.get(); + } if (connectionFactory != null) { connectionFactories.put(name, connectionFactory); } @@ -56,8 +60,8 @@ private void processKnownBeans(ArtemisRuntimeConfigs runtimeConfigs, HashSet namesToIgnore = new HashSet<>(runtimeConfigs.getAllConfigs().keySet()); - namesToIgnore.addAll(buildTimeConfigs.getAllConfigs().keySet()); + HashSet namesToIgnore = new HashSet<>(runtimeConfigs.getNames()); + namesToIgnore.addAll(buildTimeConfigs.getNames()); Map connectionFactoryNamesFromArc = ArtemisUtil .extractIdentifiers(ConnectionFactory.class, namesToIgnore); for (var entry : connectionFactoryNamesFromArc.entrySet()) {