diff --git a/build-parent/pom.xml b/build-parent/pom.xml
index 050d22fe..3ce5aa26 100644
--- a/build-parent/pom.xml
+++ b/build-parent/pom.xml
@@ -1,5 +1,6 @@
-
+
4.0.0
io.quarkiverse.artemis
@@ -28,6 +29,13 @@
pom
import
+
+ io.quarkus.platform
+ quarkus-camel-bom
+ ${camel-quarkus.platform.version}
+ pom
+ import
+
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 952ea68e..d360f0e3 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
@@ -108,6 +108,7 @@ ArtemisCoreConfiguredBuildItem configure(
return null;
}
+ boolean isSoleServerLocator = bootstrap.getConfigurationNames().size() == 1;
for (String name : bootstrap.getConfigurationNames()) {
if (!shadowRunTimeConfigs.getNames().contains(name)
&& buildTimeConfigs.getAllConfigs().getOrDefault(name, new ArtemisBuildTimeConfig()).isEmpty()) {
@@ -117,7 +118,7 @@ ArtemisCoreConfiguredBuildItem configure(
name,
runtimeConfigs,
buildTimeConfigs);
- SyntheticBeanBuildItem serverLocator = toSyntheticBeanBuildItem(name, supplier);
+ SyntheticBeanBuildItem serverLocator = toSyntheticBeanBuildItem(supplier, name, isSoleServerLocator);
syntheticBeanProducer.produce(serverLocator);
}
return new ArtemisCoreConfiguredBuildItem();
@@ -141,21 +142,23 @@ private static void addBuiltinReflectiveBuildItems(
}
private SyntheticBeanBuildItem toSyntheticBeanBuildItem(
+ Supplier supplier,
String name,
- Supplier supplier) {
+ boolean isSoleServerLocator) {
SyntheticBeanBuildItem.ExtendedBeanConfigurator configurator = SyntheticBeanBuildItem
.configure(ServerLocator.class)
.supplier(supplier)
.scope(ApplicationScoped.class);
- return addQualifiers(configurator, name)
+ return addQualifiers(name, isSoleServerLocator, configurator)
.setRuntimeInit()
.done();
}
public static SyntheticBeanBuildItem.ExtendedBeanConfigurator addQualifiers(
- SyntheticBeanBuildItem.ExtendedBeanConfigurator configurator,
- String name) {
- if (ArtemisUtil.isDefault(name)) {
+ String name,
+ boolean isSoleArtemisBean,
+ SyntheticBeanBuildItem.ExtendedBeanConfigurator configurator) {
+ if (ArtemisUtil.isDefault(name) || isSoleArtemisBean) {
configurator
.unremovable()
.addQualifier().annotation(Default.class).done();
diff --git a/docs/modules/ROOT/pages/index.adoc b/docs/modules/ROOT/pages/index.adoc
index 1167cd41..05e2ab15 100644
--- a/docs/modules/ROOT/pages/index.adoc
+++ b/docs/modules/ROOT/pages/index.adoc
@@ -105,7 +105,7 @@ public class MyClass {
}
----
-It is also registered with `@Identifier("")`, so we can inject it with
+It is also registered with link:https://github.com/smallrye/smallrye-common/blob/main/annotation/src/main/java/io/smallrye/common/annotation/Identifier.java[`@Identifier("")`], so we can inject it with
.Injection of default `ServerLocator` by its explicit name when using `quarkus-artemis-core`
[source,java,subs=attributes+]
@@ -201,8 +201,11 @@ public class MyClass {
IMPORTANT: We strongly recommend the usage of link:https://javadoc.io/doc/io.smallrye.common/smallrye-common-annotation/latest/io/smallrye/common/annotation/Identifier.html[`@Identifier` annotation] instead of the link:https://www.javadoc.io/doc/javax/javaee-api/latest/javax/inject/Named.html[`@Named` annotation]. Some other feature rely on the usage of `@Identifier`. Please see section <> for details.
+== `@Default` Bean [[default-bean]]
+When an unnamed configuration is provided, this configuration will be registered as link:https://jakarta.ee/specifications/cdi/2.0/apidocs/javax/enterprise/inject/default[`@Default`] bean. Otherwise, if only a single configuration is provided, this configuration will be registered as `@Default` bean. This mechanism allows us to inject this bean without any qualifier.
+
== Setting properties at runtime results in a warning
-When we override the properties `url`, `username` or `password` of a configuration at runtime - either through the implicit environment variable (`QUARKUS_ARTEMIS_URL`, `QUARKUS_ARTEMIS\__CONNECTION_NAME__URL`), a custom environment variable (`quarkus.artemis.url=${ARTEMIS_URL:tcp://dummy:12345}`) or a runtime-provided `.properties` files, we will see a warning at startup similar to this one:
+When we override the properties `url`, `username` or `password` of a configuration at runtime - either through the implicit environment variable (`QUARKUS_ARTEMIS_URL`, `QUARKUS_ARTEMIS\__CONNECTION_NAME__URL`), a custom environment variable (`quarkus.artemis.url=${ARTEMIS_URL:tcp://dummy:12345}`) or a runtime-provided `.properties`-/`.yaml` files, we will see a warning at startup similar to this one:
.Warning at startup
[source,subs=attributes+]
@@ -211,15 +214,56 @@ When we override the properties `url`, `username` or `password` of a configurati
- quarkus.artemis.url is set to 'tcp://localhost:61616' but it is build time fixed to 'tcp://dummy:12345'. Did you change the property quarkus.artemis.url after building the application?
----
-This is expected. We bind some properties twice: once as build-time property, once as run time property. We do so to analyze the (run time-)configuration at build time to get a list of named connections. The overwritten configuration will take effect. The correct behaviour enforced by https://github.com/quarkiverse/quarkus-artemis/tree/main/integration-tests/core/with-default-change-url[two] different https://github.com/quarkiverse/quarkus-artemis/tree/main/integration-tests/jms/with-default-change-url[tests]. The above example is taken from the logs of our tests.
+This is expected. We bind some properties twice: once as build-time property, once as run time property. We do so to analyze the (run time-)configuration at build time to get a list of named connections. The overwritten configuration will take effect. The correct behaviour is enforced by https://github.com/quarkiverse/quarkus-artemis/tree/main/integration-tests/core/with-default-change-url[two] different https://github.com/quarkiverse/quarkus-artemis/tree/main/integration-tests/jms/with-default-change-url[tests]. The above example is taken from the logs of those tests.
== Configuration detection at build-time
-We took special care so the configurations behave "as intuitively as possible". This means that if no connection-related configuration (`enabled`, `url`, `username`, `password`, `devservices...`, `health-exclude`, `xa-enabled`) is present at build-time, it is assumed that the configuration is not used and disabled. Therefore, if we want to use any configuration, but not configure it, we should set `quarkus.artemis.enabled` / `quarkus.artemis."named-configuration".enabled` to *true* to explicitly enable the configuration.
+We took special care so the configurations behave "as intuitively as possible". This means that if no connection-related configuration (`enabled`, `url`, `username`, `password`, `devservices...`, `health-exclude`, `xa-enabled`) is present at build-time, it is assumed that the configuration is not used and disabled. Therefore, if we want to use any configuration, but not configure it, we should set `quarkus.artemis.enabled` / `quarkus.artemis."named-configuration".enabled` to *true* to explicitly enable the configuration. Due to the fact how the configuration system works in quarkus, we are only able to analyze properties defined in the default profile, i.e. properties without a prefix (`%dev`, `%text`, ...). If in doubt, we recommend setting `quarkus.artemis.enabled`/`quarkus.artemis."named-configuration".enabled` to **true**.
+
+NOTE: This is also the case if we bind properties in the default profile to environment variables, without a default value. For example, `quarkus.artemis.url=$\{ARTEMIS_URL}` has no value at build-time, thus this property is "invisible" at build time.
-NOTE: binding a property to an environment variable, like `quarkus.artemis.url=$\{ARTEMIS_URL}` is sufficient, so the extension can pick up the configuration at build-time.
+NOTE: Binding a property to an environment variable, like `quarkus.artemis.url=$\{ARTEMIS_URL}` is sufficient, so the extension can pick up the configuration at build-time.
TIP: If we want to configure a connection solely through the implicit environment variables `QUARKUS_ARTEMIS_...`, we should enable the configuration by setting `quarkus.artemis.enabled` / `quarkus.artemis."named-configuration".enabled` to *true*. For example, if we want to configure connection `quarkus.artemis."named-1"` through the implicit environment variables, we would set `quarkus.artemis."named-1".enabled=true` and then configure the connection through environment variables `QUARKUS_ARTEMIS\__NAMED_1__...`.
+Table <> gives an overview when a property is visible at build time, and when it is not.
+
+.Visibility of configuration values
+[[table-visibility]]
+[cols=3*,options=header]
+|===
+| Description
+| Example
+| Visible?
+a|
+configuration property belonging to a specific profile
+a|
+* `%dev.quarkus.artemis.url=tcp://localhost:61616`
+* `%test.quarkus.artemis.password=${ARTEMIS_PASSWORD:artemis}`
+a|
+❌
+a|
+configuration property bound to constant value
+a|
+* `quarkus.artemis.url=tcp://localhost:61616`
+* `quarkus.artemis.username=artems`
+a|
+✔️
+a|
+configuration property bound to environment variable
+a|
+* `quarkus.artemis."named".url=${ARTEMIS_NAMED_URL}`
+* `quarkus.artemis.password=${ARTEMIS_PASSWORD}`
+a|
+❌
+a|
+configuration property bound to environment variable with default value
+a|
+* `quarkus.artemis."named".url=${ARTEMIS_NAMED_URL:tcp://localhost:61616}`
+* `quarkus.artemis.password=${ARTEMIS_PASSWORD:artemis}`
+a|
+✔️
+|===
+
Please do not try to configure a configuration purely through environment variables, without having any indication of its present in the application's configuration file. We specifically rely on the present of some configuration fragment at build-time to detect configurations.
== XA Transactions
@@ -228,7 +272,7 @@ XA Transactions must be activated on a per-configuration basis, they are not en
To activate XA transactions, we can set `quarkus.artemis.xa-enabled` / `quarkus.artemis."named-configuration".xa-enabled` to *true*.
== URL as optional configuration
-The `url` configuration property is optional. But in general, without a `url` property, we cannot create a connection. In case of tests with embedded resources or devservices, the corresponding annotation/service injects a url. But if the application starts up and no `url` property is found, the creation of the bean will throw a `RuntimeException` with a corresponding error message. Notice that this will happen when the bean is created. If the bean is never used (and thus never created), the exception will not occur.
+The `url` configuration property is optional. But in general, without a `url` property, we cannot create a connection. In case of tests with embedded resources or devservices, the corresponding annotation/service injects an url. But if the application starts up and no `url` property is found, the creation of the bean will throw a `RuntimeException` with a corresponding error message. Notice that this will happen when the bean is created. If the bean is never used (and thus never created), the exception will not occur.
== Health checks [[health_checks]]
By default, all configurations are added to the health check endpoint when extension `quarkus-smallrye-health` is loaded.
@@ -239,7 +283,7 @@ We can disable health checks for individual configurations by setting `quarkus.a
IMPORTANT: Note that we can only enable health checks through the above configuration if `quarkus.artemis.health.enabled` is *true*. Otherwise, setting `quarkus.artemis.health-exclude` / `quarkus.artemis."named-connection".health-exclude` has no effect.
-If we create `ServerLocator`- (extension `quarkus-artemis-core`) or `ConnectionFactory`- (extension `quarkus-artemis-jms`) beans within our application (i.e. outside of this extension), we can include them in the health check by using the link:https://javadoc.io/doc/io.smallrye.common/smallrye-common-annotation/latest/io/smallrye/common/annotation/Identifier.html[`Identifier` annotation], e.g.:
+If we create `ServerLocator`- (extension `quarkus-artemis-core`) or `ConnectionFactory`- (extension `quarkus-artemis-jms`) beans within our application (i.e. outside of this extension), we can include them in the health check by using the link:https://javadoc.io/doc/io.smallrye.common/smallrye-common-annotation/latest/io/smallrye/common/annotation/Identifier.html[`@Identifier` annotation], e.g.:
.Defining a `ServerLocator`-bean that is picked up automatically by health checks
[source,java,subs=attributes+]
@@ -273,6 +317,36 @@ If we do not want that beans created within our application is picked up by the
IMPORTANT: Note that `ServerLocator` s / `ConnectionFactory` s are only picked up when `quarkus.artemis.health.enabled` is *true*.
+== Camel support
+All connection factories that are configured through `quarkus-artemis-jms` are automatically registered in the camel context, if the program uses camel. This allows us to reference the connection factories by name, e.g.:
+
+.Referencing `ConnectionFactory` s in a camel route by their bean name
+[source,java,subs=attributes+]
+----
+from(jms("queue:in").connectionFactory(""))
+ .to(jms("queue:out").connectionFactory("named"));
+----
+
+As with <>, connection factories that are defined outside this extension, but are annotated with link:https://github.com/smallrye/smallrye-common/blob/main/annotation/src/main/java/io/smallrye/common/annotation/Identifier.java[`@Identifier`] are treated the same way. So if we define a `ConnectionFactory`-bean in our code, e.g. through a method annotated with link:https://jakarta.ee/specifications/cdi/4.0/apidocs/jakarta.cdi/jakarta/enterprise/inject/produces[`@Produces`] and, for example, `@Identifier("externally-defined")`, we can use this `ConnectionFactory` as follows:
+
+.Referencing an externally defined `ConnectionFactory`-bean by its name
+[source,java,subs=attributes+]
+----
+from(jms("queue:in").connectionFactory("externally-defined"))
+ .to(jms("queue:out").connectionFactory("externally-defined"));
+----
+
+Finally, if only a single `ConnectionFactory` is defined through `quarkus-artemis-jms`, this `ConnectionFactory` is always registered as link:https://jakarta.ee/specifications/cdi/2.0/apidocs/javax/enterprise/inject/default[`@Default`] bean (see Section <>). This allows us to use this `ConnectionFactory` implicitly in a camel route, without setting it explicitly:
+
+.Implicitly use the only `ConnectionFactory`-bean defined in the application
+[source,java,subs=attributes+]
+----
+from(jms("queue:in"))
+ .to(jms("queue:out"));
+----
+
+This also works for an externally defined `ConnectionFactory`, as long as it is defined as `@Default`. This mechanism stops working as soon as more than one `ConnectionFactory` bean is defined in the application.
+
== Artemis DevServices
Artemis DevServices are automatically enabled unless `quarkus.artemis.url` / `quarkus.artemis."named-configuration".url` is set or `quarkus.artemis.devservices.enabled` / `quarkus.artemis."named-configuration".enabled` is *false* explicitly. And if you still want to use `ArtemisTestResource` in the test, you need to disable artemis devservices.
@@ -298,7 +372,7 @@ This instance can be configured by placing a `broker-named-1.xml` in `src/test/r
For an in-depth explanation of what can be configured in a `broker.xml`, please see the link:https://activemq.apache.org/components/artemis/documentation/latest/configuration-index.html:[official Artemis documentation].
== Examples
-Examples can be found in the `integration-tests` module, e.g
+Examples can be found in the `integration-tests` module, e.g.
https://github.com/quarkiverse/quarkus-artemis/tree/2.0.0/integration-tests/core/with-default[The Apache ActiveMQ Artemis Core integration with default configuration tests module]
[[extension-configuration-reference]]
diff --git a/integration-tests/camel-jms/pom.xml b/integration-tests/camel-jms/pom.xml
new file mode 100644
index 00000000..2879b2b8
--- /dev/null
+++ b/integration-tests/camel-jms/pom.xml
@@ -0,0 +1,42 @@
+
+
+ 4.0.0
+
+ io.quarkiverse.artemis
+ quarkus-artemis-integration-tests-parent
+ 999-SNAPSHOT
+
+
+ quarkus-integration-test-artemis-camel-jms-parent
+ Quarkus - Artemis - Integration Tests - Camel JMS Parent
+ The Apache ActiveMQ Artemis Camel JMS integration tests parent module
+
+ pom
+
+ with-default
+ with-default-and-named
+ with-external
+ with-named
+ with-named-and-external
+
+
+
+
+
+
+
+
+
+ io.quarkiverse.artemis
+ quarkus-artemis-jms
+
+
+
+
+ org.apache.camel.quarkus
+ camel-quarkus-jms
+
+
+
\ No newline at end of file
diff --git a/integration-tests/camel-jms/with-default-and-named/pom.xml b/integration-tests/camel-jms/with-default-and-named/pom.xml
new file mode 100644
index 00000000..90aba5f2
--- /dev/null
+++ b/integration-tests/camel-jms/with-default-and-named/pom.xml
@@ -0,0 +1,15 @@
+
+
+ 4.0.0
+
+ io.quarkiverse.artemis
+ quarkus-integration-test-artemis-camel-jms-parent
+ 999-SNAPSHOT
+
+
+ quarkus-integration-test-artemis-camel-jms-with-default-and-named
+ Quarkus - Artemis - Integration Tests - Camel JMS - With default and named configuration
+ The Apache ActiveMQ Artemis Camel JMS integration tests with default and named configuration module
+
diff --git a/integration-tests/camel-jms/with-default-and-named/src/main/java/io/quarkus/it/artemis/camel/jms/withdefaultandnamed/ArtemisConsumerManager.java b/integration-tests/camel-jms/with-default-and-named/src/main/java/io/quarkus/it/artemis/camel/jms/withdefaultandnamed/ArtemisConsumerManager.java
new file mode 100644
index 00000000..f2799384
--- /dev/null
+++ b/integration-tests/camel-jms/with-default-and-named/src/main/java/io/quarkus/it/artemis/camel/jms/withdefaultandnamed/ArtemisConsumerManager.java
@@ -0,0 +1,39 @@
+package io.quarkus.it.artemis.camel.jms.withdefaultandnamed;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Produces;
+import javax.jms.ConnectionFactory;
+import javax.jms.JMSConsumer;
+import javax.jms.JMSContext;
+import javax.jms.JMSException;
+
+import io.smallrye.common.annotation.Identifier;
+
+public class ArtemisConsumerManager {
+ static class Producer {
+ @Produces
+ @ApplicationScoped
+ @Identifier("named")
+ ArtemisConsumerManager namedConsumerManager(
+ @SuppressWarnings("CdiInjectionPointsInspection") @Identifier("named") ConnectionFactory connectionFactory) {
+ return new ArtemisConsumerManager(connectionFactory, "out");
+ }
+ }
+
+ private final ConnectionFactory connectionFactory;
+ private final String queueName;
+
+ public ArtemisConsumerManager(ConnectionFactory connectionFactory, String queueName) {
+ this.connectionFactory = connectionFactory;
+ this.queueName = queueName;
+ }
+
+ public String receive() {
+ try (JMSContext context = connectionFactory.createContext(JMSContext.AUTO_ACKNOWLEDGE);
+ JMSConsumer consumer = context.createConsumer(context.createQueue(queueName))) {
+ return consumer.receive(1000L).getBody(String.class);
+ } catch (JMSException e) {
+ throw new RuntimeException("Could not receive message", e);
+ }
+ }
+}
diff --git a/integration-tests/camel-jms/with-default-and-named/src/main/java/io/quarkus/it/artemis/camel/jms/withdefaultandnamed/ArtemisEndpoint.java b/integration-tests/camel-jms/with-default-and-named/src/main/java/io/quarkus/it/artemis/camel/jms/withdefaultandnamed/ArtemisEndpoint.java
new file mode 100644
index 00000000..aed93853
--- /dev/null
+++ b/integration-tests/camel-jms/with-default-and-named/src/main/java/io/quarkus/it/artemis/camel/jms/withdefaultandnamed/ArtemisEndpoint.java
@@ -0,0 +1,30 @@
+package io.quarkus.it.artemis.camel.jms.withdefaultandnamed;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import io.smallrye.common.annotation.Identifier;
+
+@Path("send-and-receive")
+@Consumes(MediaType.TEXT_PLAIN)
+@Produces(MediaType.TEXT_PLAIN)
+public class ArtemisEndpoint {
+ private final ArtemisProducerManager defaultProducerManager;
+ private final ArtemisConsumerManager namedConsumerManager;
+
+ public ArtemisEndpoint(
+ ArtemisProducerManager defaultProducerManager,
+ @Identifier("named") ArtemisConsumerManager namedConsumerManager) {
+ this.defaultProducerManager = defaultProducerManager;
+ this.namedConsumerManager = namedConsumerManager;
+ }
+
+ @POST
+ public String sendAndReceive(String message) {
+ defaultProducerManager.send(message);
+ return namedConsumerManager.receive();
+ }
+}
diff --git a/integration-tests/camel-jms/with-default-and-named/src/main/java/io/quarkus/it/artemis/camel/jms/withdefaultandnamed/ArtemisProducerManager.java b/integration-tests/camel-jms/with-default-and-named/src/main/java/io/quarkus/it/artemis/camel/jms/withdefaultandnamed/ArtemisProducerManager.java
new file mode 100644
index 00000000..db9adfa5
--- /dev/null
+++ b/integration-tests/camel-jms/with-default-and-named/src/main/java/io/quarkus/it/artemis/camel/jms/withdefaultandnamed/ArtemisProducerManager.java
@@ -0,0 +1,42 @@
+package io.quarkus.it.artemis.camel.jms.withdefaultandnamed;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Produces;
+import javax.jms.ConnectionFactory;
+import javax.jms.JMSContext;
+import javax.jms.JMSProducer;
+
+public class ArtemisProducerManager {
+ static class Producer {
+ @Produces
+ @ApplicationScoped
+ ArtemisProducerManager defaultProducerManager(
+ @SuppressWarnings("CdiInjectionPointsInspection") ConnectionFactory defaultConnectionFactory) {
+ return new ArtemisProducerManager(defaultConnectionFactory, "in");
+ }
+
+ Producer() {
+ }
+ }
+
+ private final ConnectionFactory connectionFactory;
+ private final String queueName;
+
+ private ArtemisProducerManager(
+ ConnectionFactory connectionFactory,
+ String queueName) {
+ this.connectionFactory = connectionFactory;
+ this.queueName = queueName;
+ }
+
+ private void send(JMSContext context, String body) {
+ JMSProducer producer = context.createProducer();
+ producer.send(context.createQueue(queueName), body);
+ }
+
+ public void send(String body) {
+ try (JMSContext context = connectionFactory.createContext(JMSContext.AUTO_ACKNOWLEDGE)) {
+ send(context, body);
+ }
+ }
+}
diff --git a/integration-tests/camel-jms/with-default-and-named/src/main/java/io/quarkus/it/artemis/camel/jms/withdefaultandnamed/TransferRoute.java b/integration-tests/camel-jms/with-default-and-named/src/main/java/io/quarkus/it/artemis/camel/jms/withdefaultandnamed/TransferRoute.java
new file mode 100644
index 00000000..f8df7838
--- /dev/null
+++ b/integration-tests/camel-jms/with-default-and-named/src/main/java/io/quarkus/it/artemis/camel/jms/withdefaultandnamed/TransferRoute.java
@@ -0,0 +1,15 @@
+package io.quarkus.it.artemis.camel.jms.withdefaultandnamed;
+
+import static org.apache.camel.builder.endpoint.StaticEndpointBuilders.jms;
+
+import org.apache.camel.builder.RouteConfigurationBuilder;
+
+@SuppressWarnings("unused")
+public class TransferRoute extends RouteConfigurationBuilder {
+
+ @Override
+ public void configuration() {
+ from(jms("queue:in").connectionFactory(""))
+ .to(jms("queue:out").connectionFactory("named"));
+ }
+}
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
new file mode 100644
index 00000000..24631638
--- /dev/null
+++ b/integration-tests/camel-jms/with-default-and-named/src/main/resources/application.properties
@@ -0,0 +1,2 @@
+quarkus.artemis.devservices.enabled=false
+quarkus.artemis."named".devservices.enabled=false
\ 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/ArtemisHealthCheckHelper.java b/integration-tests/camel-jms/with-default-and-named/src/test/java/io/quarkus/it/artemis/camel/jms/withdefaultandnamed/ArtemisHealthCheckHelper.java
new file mode 100644
index 00000000..99a896d5
--- /dev/null
+++ b/integration-tests/camel-jms/with-default-and-named/src/test/java/io/quarkus/it/artemis/camel/jms/withdefaultandnamed/ArtemisHealthCheckHelper.java
@@ -0,0 +1,37 @@
+package io.quarkus.it.artemis.camel.jms.withdefaultandnamed;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.junit.jupiter.api.Assertions;
+
+import io.restassured.RestAssured;
+import io.restassured.common.mapper.TypeRef;
+import io.restassured.response.Response;
+
+public abstract class ArtemisHealthCheckHelper {
+
+ public static void test(String endpoint, Set expectedConfigurations) {
+ Response response = RestAssured.with().get(endpoint);
+ Assertions.assertEquals(javax.ws.rs.core.Response.Status.OK.getStatusCode(), response.statusCode());
+
+ Map body = response.as(new TypeRef<>() {
+ });
+ Assertions.assertEquals("UP", body.get("status"));
+
+ @SuppressWarnings("unchecked")
+ List
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 45e90343..fad99684 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
@@ -53,17 +53,22 @@ ArtemisJmsConfiguredBuildItem configure(
return null;
}
ArtemisJmsWrapper wrapper = getWrapper(recorder, wrapperItem);
- final Set configurationNames = bootstrap.getConfigurationNames();
+ 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.getAllConfigs().getOrDefault(name,
+ new ArtemisBuildTimeConfig()).isEmpty()) {
continue;
}
- Supplier connectionFactorySupplier = recorder.getConnectionFactoryProducer(name, runtimeConfigs,
- buildTimeConfigs, wrapper);
- syntheticBeanProducer.produce(toSyntheticBeanBuildItem(
+ Supplier connectionFactorySupplier = recorder.getConnectionFactoryProducer(
name,
+ runtimeConfigs,
+ buildTimeConfigs,
+ wrapper);
+ syntheticBeanProducer.produce(toSyntheticBeanBuildItem(
connectionFactorySupplier,
+ name,
+ isSoleConnectionFactory,
buildTimeConfigs.getAllConfigs().getOrDefault(name,
new ArtemisBuildTimeConfig()).isXaEnabled()));
}
@@ -83,13 +88,14 @@ private static ArtemisJmsWrapper getWrapper(
}
private static SyntheticBeanBuildItem toSyntheticBeanBuildItem(
- String name,
Supplier connectionFactorySupplier,
+ String name,
+ boolean isSoleConnectionFactory,
boolean isXaEnable) {
SyntheticBeanBuildItem.ExtendedBeanConfigurator configurator = initializeConfigurator(isXaEnable)
.supplier(connectionFactorySupplier)
.scope(ApplicationScoped.class);
- return ArtemisCoreProcessor.addQualifiers(configurator, name)
+ return ArtemisCoreProcessor.addQualifiers(name, isSoleConnectionFactory, configurator)
.setRuntimeInit()
.done();
}
diff --git a/jms/deployment/src/main/java/io/quarkus/artemis/jms/deployment/camel/CamelJmsRegistryEnhancerProcessor.java b/jms/deployment/src/main/java/io/quarkus/artemis/jms/deployment/camel/CamelJmsRegistryEnhancerProcessor.java
new file mode 100644
index 00000000..beb2f77e
--- /dev/null
+++ b/jms/deployment/src/main/java/io/quarkus/artemis/jms/deployment/camel/CamelJmsRegistryEnhancerProcessor.java
@@ -0,0 +1,19 @@
+package io.quarkus.artemis.jms.deployment.camel;
+
+import org.apache.camel.quarkus.core.CamelCapabilities;
+
+import io.quarkus.arc.deployment.AdditionalBeanBuildItem;
+import io.quarkus.artemis.jms.runtime.camel.CamelContextEnhancer;
+import io.quarkus.deployment.Capabilities;
+import io.quarkus.deployment.annotations.BuildStep;
+
+public class CamelJmsRegistryEnhancerProcessor {
+ @SuppressWarnings("unused")
+ @BuildStep
+ AdditionalBeanBuildItem addCamelContextEnhancer(Capabilities capabilities) {
+ if (capabilities.isPresent(CamelCapabilities.CORE)) {
+ return AdditionalBeanBuildItem.unremovableOf(CamelContextEnhancer.class);
+ }
+ return null;
+ }
+}
diff --git a/jms/runtime/pom.xml b/jms/runtime/pom.xml
index 1e603bfc..9c0dd3ae 100644
--- a/jms/runtime/pom.xml
+++ b/jms/runtime/pom.xml
@@ -49,5 +49,11 @@
org.apache.activemq
artemis-jms-client
+
+
+ org.apache.camel.quarkus
+ camel-quarkus-core
+ true
+
diff --git a/jms/runtime/src/main/java/io/quarkus/artemis/jms/runtime/camel/CamelContextEnhancer.java b/jms/runtime/src/main/java/io/quarkus/artemis/jms/runtime/camel/CamelContextEnhancer.java
new file mode 100644
index 00000000..75e8c2c5
--- /dev/null
+++ b/jms/runtime/src/main/java/io/quarkus/artemis/jms/runtime/camel/CamelContextEnhancer.java
@@ -0,0 +1,23 @@
+package io.quarkus.artemis.jms.runtime.camel;
+
+import java.util.Collections;
+import java.util.Map;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.event.Observes;
+import javax.jms.ConnectionFactory;
+
+import org.apache.camel.impl.event.CamelContextInitializingEvent;
+
+import io.quarkus.artemis.core.runtime.ArtemisUtil;
+
+@ApplicationScoped
+public class CamelContextEnhancer {
+ void startUp(@Observes CamelContextInitializingEvent event) {
+ Map connectionFactoryNamesFromArc = ArtemisUtil
+ .extractIdentifiers(ConnectionFactory.class, Collections.emptySet());
+ for (var entry : connectionFactoryNamesFromArc.entrySet()) {
+ event.getContext().getRegistry().bind(entry.getKey(), entry.getValue());
+ }
+ }
+}
diff --git a/pom.xml b/pom.xml
index ea5ece4c..42c71057 100644
--- a/pom.xml
+++ b/pom.xml
@@ -32,6 +32,8 @@
2.15.1.Final
2.26.0
+ quarkus-camel-bom
+ 2.15.0.CR1