Skip to content

Commit

Permalink
Fix #5068 to add a pooling test with quarkus-qpid-jms (#5069)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhfeng committed Jul 7, 2023
1 parent 279944f commit 65a5ce1
Show file tree
Hide file tree
Showing 13 changed files with 316 additions and 14 deletions.
21 changes: 16 additions & 5 deletions docs/modules/ROOT/pages/reference/extensions/amqp.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,25 @@ you must ensure that the `camel-quarkus-xml-jaxp` extension is present on the cl
When sending JMS message payloads as `javax.jms.ObjectMessage`, you must annotate the relevant classes to be registered for serialization with `@RegisterForReflection(serialization = true)`.
Note that this extension automatically sets `quarkus.camel.native.reflection.serialization-enabled = true` for you. Refer to the xref:user-guide/native-mode.adoc#serialization[native mode user guide] for more information.

[id="extensions-amqp-usage-connection-pooling"]
=== Connection Pooling

[id="extensions-amqp-camel-quarkus-limitations"]
== Camel Quarkus limitations
You can use the `quarkus-pooled-jms` extension to get pooling support for the connections. Refer to the https://quarkiverse.github.io/quarkiverse-docs/quarkus-pooled-jms/dev/index.html[quarkus-pooled-jms] extension documentation for more information.

[id="extensions-amqp-limitations-connection-pooling"]
=== Connection Pooling
Just add the following dependency to your `pom.xml`:
[source,xml]
----
<dependency>
<groupId>io.quarkiverse.messaginghub</groupId>
<artifactId>quarkus-pooled-jms</artifactId>
</dependency>
----

JMS connection pooling isn't supported yet since there is still an open https://github.com/amqphub/quarkus-qpid-jms/issues/22[issue] with quarkus-qpid-jms.
To enable the pooling support, you need to add the following configuration to your `application.properties`:
[source,properties]
----
quarkus.qpid-jms.wrap=true
----


[id="extensions-amqp-transferexception-option-in-native-mode"]
Expand Down
3 changes: 0 additions & 3 deletions extensions/amqp/runtime/src/main/doc/limitations.adoc

This file was deleted.

19 changes: 19 additions & 0 deletions extensions/amqp/runtime/src/main/doc/usage.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,22 @@ you must ensure that the `camel-quarkus-xml-jaxp` extension is present on the cl

When sending JMS message payloads as `javax.jms.ObjectMessage`, you must annotate the relevant classes to be registered for serialization with `@RegisterForReflection(serialization = true)`.
Note that this extension automatically sets `quarkus.camel.native.reflection.serialization-enabled = true` for you. Refer to the xref:user-guide/native-mode.adoc#serialization[native mode user guide] for more information.

=== Connection Pooling

You can use the `quarkus-pooled-jms` extension to get pooling support for the connections. Refer to the https://quarkiverse.github.io/quarkiverse-docs/quarkus-pooled-jms/dev/index.html[quarkus-pooled-jms] extension documentation for more information.

Just add the following dependency to your `pom.xml`:
[source,xml]
----
<dependency>
<groupId>io.quarkiverse.messaginghub</groupId>
<artifactId>quarkus-pooled-jms</artifactId>
</dependency>
----

To enable the pooling support, you need to add the following configuration to your `application.properties`:
[source,properties]
----
quarkus.qpid-jms.wrap=true
----
6 changes: 6 additions & 0 deletions integration-tests/amqp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@
<artifactId>camel-quarkus-integration-test-messaging-jms</artifactId>
</dependency>

<!-- Messaging Pooled JMS -->
<dependency>
<groupId>io.quarkiverse.messaginghub</groupId>
<artifactId>quarkus-pooled-jms</artifactId>
</dependency>

<!-- test dependencies -->
<dependency>
<groupId>io.quarkus</groupId>
Expand Down
19 changes: 19 additions & 0 deletions integration-tests/amqp/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## ---------------------------------------------------------------------------
## Licensed to the Apache Software Foundation (ASF) under one or more
## contributor license agreements. See the NOTICE file distributed with
## this work for additional information regarding copyright ownership.
## The ASF licenses this file to You under the Apache License, Version 2.0
## (the "License"); you may not use this file except in compliance with
## the License. You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
## ---------------------------------------------------------------------------
#
# Only enabled with AmqpPoolingTest
quarkus.pooled-jms.pooling.enabled=false
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.camel.quarkus.component.amqp.it;

import io.quarkus.test.junit.QuarkusIntegrationTest;

@QuarkusIntegrationTest
class AmqpPoolingIT extends AmqpPoolingTest {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.camel.quarkus.component.amqp.it;

import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.common.ResourceArg;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.TestProfile;
import io.restassured.RestAssured;
import org.apache.camel.quarkus.messaging.jms.AbstractJmsMessagingTest;
import org.apache.camel.quarkus.test.support.activemq.ActiveMQTestResource;
import org.junit.jupiter.api.Test;

import static org.hamcrest.Matchers.containsString;

@QuarkusTest
@QuarkusTestResource(initArgs = {
@ResourceArg(name = "modules", value = "quarkus.qpid-jms")
}, value = ActiveMQTestResource.class)
@TestProfile(JmsPoolingEnabled.class)
class AmqpPoolingTest extends AbstractJmsMessagingTest {

@Test
public void connectionFactoryImplementation() {
RestAssured.get("/amqp/connection/factory")
.then()
.statusCode(200)
.body(containsString("qpid"));
}

@Override
public void testJmsTopic() {
// Ignore testJmsTopic since it can't use setClientId in a pool connection.
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.camel.quarkus.component.amqp.it;

import java.util.HashMap;
import java.util.Map;

import io.quarkus.test.junit.QuarkusTestProfile;

public class JmsPoolingEnabled implements QuarkusTestProfile {
@Override
public Map<String, String> getConfigOverrides() {
Map<String, String> props = new HashMap<>();
props.put("quarkus.pooled-jms.pooling.enabled", "true");
props.put("quarkus.pooled-jms.max-connections", "8");
props.put("quarkus.qpid-jms.wrap", "true");
return props;
}
}
13 changes: 7 additions & 6 deletions integration-tests/jms-qpid-amqp-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@
<artifactId>camel-quarkus-jms</artifactId>
</dependency>

<!-- Messaging Pooled JMS -->
<dependency>
<groupId>io.quarkiverse.messaginghub</groupId>
<artifactId>quarkus-pooled-jms</artifactId>
</dependency>

<!-- Inherit base messaging routes -->
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
Expand All @@ -47,13 +53,8 @@
<dependency>
<groupId>org.amqphub.quarkus</groupId>
<artifactId>quarkus-qpid-jms</artifactId>
<exclusions>
<exclusion><!-- Remove this once https://github.com/apache/qpid-jms/pull/46 reaches us -->
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jms_2.0_spec</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>jakarta.jms</groupId>
<artifactId>jakarta.jms-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## ---------------------------------------------------------------------------
## Licensed to the Apache Software Foundation (ASF) under one or more
## contributor license agreements. See the NOTICE file distributed with
## this work for additional information regarding copyright ownership.
## The ASF licenses this file to You under the Apache License, Version 2.0
## (the "License"); you may not use this file except in compliance with
## the License. You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
## ---------------------------------------------------------------------------
#
# Only enabled with JmsQpidPoolingTest
quarkus.pooled-jms.pooling.enabled=false
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.camel.quarkus.component.jms.qpid.it;

import java.util.HashMap;
import java.util.Map;

import io.quarkus.test.junit.QuarkusTestProfile;

public class JmsPoolingEnabled implements QuarkusTestProfile {
@Override
public Map<String, String> getConfigOverrides() {
Map<String, String> props = new HashMap<>();
props.put("quarkus.pooled-jms.pooling.enabled", "true");
props.put("quarkus.pooled-jms.max-connections", "8");
props.put("quarkus.qpid-jms.wrap", "true");
return props;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.camel.quarkus.component.jms.qpid.it;

import io.quarkus.test.junit.QuarkusIntegrationTest;

@QuarkusIntegrationTest
public class JmsQpidPoolingIT extends JmsQpidPoolingTest {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.camel.quarkus.component.jms.qpid.it;

import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.common.ResourceArg;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.TestProfile;
import io.restassured.RestAssured;
import org.apache.camel.quarkus.messaging.jms.AbstractJmsMessagingTest;
import org.apache.camel.quarkus.test.support.activemq.ActiveMQTestResource;
import org.junit.jupiter.api.Test;

import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;

@QuarkusTest
@QuarkusTestResource(initArgs = {
@ResourceArg(name = "modules", value = "quarkus.qpid-jms") }, value = ActiveMQTestResource.class)
@TestProfile(JmsPoolingEnabled.class)
class JmsQpidPoolingTest extends AbstractJmsMessagingTest {

@Test
public void connectionFactoryImplementation() {
RestAssured.get("/messaging/jms/qpid/connection/factory")
.then()
.statusCode(200)
.body(containsString("qpid"));
}

@Test
public void testPojoProducer() {
String message = "Camel Quarkus qPid AMQP Pojo Producer";

RestAssured.given()
.body(message)
.post("/messaging/jms/qpid/pojo/producer")
.then()
.statusCode(204);

RestAssured.get("/messaging/{queueName}", "pojoProduce")
.then()
.statusCode(200)
.body(is(message));
}

@Override
public void testJmsTopic() {
// Ignore testJmsTopic since it can't use setClientId in a pool connection.
}

}

0 comments on commit 65a5ce1

Please sign in to comment.