[
https://issues.apache.org/jira/browse/KARAF-5721?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16490692#comment-16490692
]
ASF GitHub Bot commented on KARAF-5721:
---------------------------------------
jbonofre closed pull request #499: [KARAF-5721] Upgrade to PAX JMS 1.0.1
URL: https://github.com/apache/karaf/pull/499
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/assemblies/features/enterprise/src/main/feature/feature.xml
b/assemblies/features/enterprise/src/main/feature/feature.xml
index b12a5e1ae7..20120d3c29 100644
--- a/assemblies/features/enterprise/src/main/feature/feature.xml
+++ b/assemblies/features/enterprise/src/main/feature/feature.xml
@@ -230,6 +230,8 @@
<feature name="jms" description="JMS service and commands"
version="${project.version}">
<details>JMS support provinding service, commands, and MBean.</details>
<feature>pax-jms-pool</feature>
+ <feature>pax-jms-config</feature>
+ <feature>pax-jms-pool-transx</feature>
<feature>transaction</feature>
<bundle dependency="true">mvn:javax.jms/javax.jms-api/2.0</bundle>
<bundle
dependency="true">mvn:org.apache.geronimo.specs/geronimo-jta_1.1_spec/${geronimo.jta-spec.version}</bundle>
diff --git
a/itests/common/src/main/java/org/apache/karaf/itests/KarafTestWatcher.java
b/itests/common/src/main/java/org/apache/karaf/itests/KarafTestWatcher.java
index 2e6ea47422..9dc9b7dd49 100644
--- a/itests/common/src/main/java/org/apache/karaf/itests/KarafTestWatcher.java
+++ b/itests/common/src/main/java/org/apache/karaf/itests/KarafTestWatcher.java
@@ -33,6 +33,7 @@ protected void starting(Description description) {
@Override
protected void failed(Throwable e, Description description) {
LOG.error(">>>>>> FAILED: {} , cause: {}",
description.getDisplayName(), e.getMessage());
+ e.printStackTrace();
}
@Override
diff --git a/itests/test/src/test/java/org/apache/karaf/itests/JmsTest.java
b/itests/test/src/test/java/org/apache/karaf/itests/JmsTest.java
index e3bc9d0aed..2530c6fcde 100644
--- a/itests/test/src/test/java/org/apache/karaf/itests/JmsTest.java
+++ b/itests/test/src/test/java/org/apache/karaf/itests/JmsTest.java
@@ -64,7 +64,7 @@
return new Option[] //
{
composite(super.config()), //
- features(activeMqUrl, "jms", "activemq-broker-noweb", "shell-compat"),
+ features(activeMqUrl, "jms", "pax-jms-activemq",
"activemq-broker-noweb", "shell-compat"),
features(springLegacyUrl, "spring")
};
}
@@ -128,7 +128,7 @@ private String execute(String command) {
}
private void checkJMXCreateConnectionFactory() throws Exception {
- invoke("create", JMX_CF_NAME, "activemq", "tcp://localhost:61616",
"karaf", "karaf");
+ invoke("create", JMX_CF_NAME, "activemq", "tcp://localhost:61616",
"karaf", "karaf", "transx");
waitForConnectionFactory("name=" + JMX_CF_NAME);
@SuppressWarnings("unchecked")
List<String> connectionFactories =
(List<String>)mbeanServer.getAttribute(objName,
diff --git
a/itests/test/src/test/java/org/apache/karaf/itests/features/XATest.java
b/itests/test/src/test/java/org/apache/karaf/itests/features/XATest.java
index d32d2a0058..779b0bbf7e 100644
--- a/itests/test/src/test/java/org/apache/karaf/itests/features/XATest.java
+++ b/itests/test/src/test/java/org/apache/karaf/itests/features/XATest.java
@@ -25,6 +25,7 @@
import org.ops4j.pax.exam.junit.PaxExam;
import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
import org.ops4j.pax.exam.spi.reactors.PerClass;
+import org.ops4j.pax.exam.spi.reactors.PerMethod;
import org.osgi.framework.Bundle;
import java.util.Arrays;
@@ -55,8 +56,8 @@
"mvn:org.apache.karaf.features/enterprise/" + version +
"/xml/features, " +
"mvn:org.apache.karaf.features/spring-legacy/" + version +
"/xml/features, " +
"mvn:org.apache.karaf.features/standard/" + version +
"/xml/features, " +
- "mvn:org.apache.activemq/artemis-features/2.2.0/xml/features,
" +
- "mvn:org.apache.camel.karaf/apache-camel/2.19.2/xml/features"
+ "mvn:org.apache.activemq/artemis-features/2.6.0/xml/features,
" +
+ "mvn:org.apache.camel.karaf/apache-camel/2.20.1/xml/features"
));
result.add(replaceConfigurationFile("etc/org.ops4j.connectionfactory-artemis.cfg",
getConfigFile("/org/apache/karaf/itests/features/org.ops4j.connectionfactory-artemis.cfg")));
result.add(replaceConfigurationFile("etc/org.ops4j.datasource-derby.cfg",
getConfigFile("/org/apache/karaf/itests/features/org.ops4j.datasource-derby.cfg")));
@@ -71,29 +72,46 @@
}
@Test
- public void installFeature() throws Exception {
- featureService.installFeatures(asSet(
- "transaction",
- "transaction-manager-narayana",
- "artemis",
- "pax-jms-pool",
- "jms",
- "pax-jdbc-derby",
- "pax-jdbc-pool-transx",
- "jdbc",
- "shell-compat",
- "camel-blueprint",
- "camel-spring",
- "camel-sql",
- "camel-jms"), NO_AUTO_REFRESH);
+ public void test() throws Exception {
+ featureService.installFeature("aries-blueprint");
+
+ System.out.println("== Installing Artemis");
+ featureService.installFeature("artemis", NO_AUTO_REFRESH);
+ featureService.installFeature("jms", NO_AUTO_REFRESH);
+ featureService.installFeature("pax-jms-artemis", NO_AUTO_REFRESH);
+
+ System.out.println(" ");
+ System.out.println(executeCommand("jms:info artemis"));
+
+ System.out.println("== Installing Derby");
+ featureService.installFeature("jdbc", NO_AUTO_REFRESH);
+ featureService.installFeature("pax-jdbc-derby", NO_AUTO_REFRESH);
+ featureService.installFeature("pax-jdbc-pool-transx", NO_AUTO_REFRESH);
+
+ System.out.println(" ");
+ System.out.println(executeCommand("jdbc:ds-list"));
+
+ System.out.println("== Install Camel route");
+ featureService.installFeature("camel-blueprint", NO_AUTO_REFRESH);
+ featureService.installFeature("camel-sql", NO_AUTO_REFRESH);
+ featureService.installFeature("camel-jms", NO_AUTO_REFRESH);
+
+ featureService.installFeature("transaction-manager-narayana",
NO_AUTO_REFRESH);
Bundle bundle =
bundleContext.installBundle("blueprint:file:etc/xa-test-camel.xml");
bundle.start();
- executeCommand("jdbc:execute derby CREATE TABLE messages (id INTEGER
NOT NULL GENERATED ALWAYS AS IDENTITY, message VARCHAR(1024) NOT NULL,
CONSTRAINT primary_key PRIMARY KEY (id))");
- executeCommand("jms:send artemis MyQueue 'the-message'");
+ Thread.sleep(5000);
- Thread.sleep(1000);
+ System.out.println(executeCommand("camel:route-list"));
+
+ System.out.println("== Creating tables in Derby");
+ System.out.println(executeCommand("jdbc:execute derby CREATE TABLE
messages (id INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY, message
VARCHAR(1024) NOT NULL, CONSTRAINT primary_key PRIMARY KEY (id))"));
+
+ System.out.println("== Sending a message in Artemis broker that should
be consumed by Camel route and inserted into the Derby database");
+ System.out.println(executeCommand("jms:send artemis MyQueue
'the-message'"));
+
+ Thread.sleep(5000);
String output = executeCommand("jdbc:query derby select * from
messages");
System.err.println(output);
@@ -102,8 +120,4 @@ public void installFeature() throws Exception {
}
- private static Set<String> asSet(String... strings) {
- return new HashSet<>(Arrays.asList(strings));
- }
-
}
diff --git
a/itests/test/src/test/resources/org/apache/karaf/itests/features/org.ops4j.datasource-derby.cfg
b/itests/test/src/test/resources/org/apache/karaf/itests/features/org.ops4j.datasource-derby.cfg
index 3dfe2c8291..64ade0b1e8 100644
---
a/itests/test/src/test/resources/org/apache/karaf/itests/features/org.ops4j.datasource-derby.cfg
+++
b/itests/test/src/test/resources/org/apache/karaf/itests/features/org.ops4j.datasource-derby.cfg
@@ -19,6 +19,7 @@
osgi.jdbc.driver.name = derby
osgi.jndi.service.name = derby
+osgi.jdbc.driver.class = org.apache.derby.jdbc.EmbeddedDriver
url = jdbc:derby:data/derby/test;create=true
pool = transx
xa = true
diff --git a/jms/src/main/java/org/apache/karaf/jms/JmsMBean.java
b/jms/src/main/java/org/apache/karaf/jms/JmsMBean.java
index d62a9baf89..ff5b2d73d7 100644
--- a/jms/src/main/java/org/apache/karaf/jms/JmsMBean.java
+++ b/jms/src/main/java/org/apache/karaf/jms/JmsMBean.java
@@ -52,9 +52,10 @@
* @param url The JMS connection factory URL. NB: when type is
WebsphereMQ, the URL has the format host/port/queuemanager/channel.
* @param username The JMS connection factory authentication username.
* @param password The JMS connection factory authentication password.
+ * @param pool The JMS connection factory pooling to use.
* @throws MBeanException If the MBean fails.
*/
- void create(String name, String type, String url, String username, String
password) throws MBeanException;
+ void create(String name, String type, String url, String username, String
password, String pool) throws MBeanException;
/**
* Delete a JMS connection factory.
diff --git a/jms/src/main/java/org/apache/karaf/jms/JmsService.java
b/jms/src/main/java/org/apache/karaf/jms/JmsService.java
index 0902e33d45..1a4237c3d0 100644
--- a/jms/src/main/java/org/apache/karaf/jms/JmsService.java
+++ b/jms/src/main/java/org/apache/karaf/jms/JmsService.java
@@ -58,9 +58,10 @@
* @param url The JMS URL to use.
* @param username The username to use.
* @param password The password to use.
+ * @param pool Kind of pool to use.
* @throws Exception If the service fails.
*/
- void create(String name, String type, String url, String username, String
password) throws Exception;
+ void create(String name, String type, String url, String username, String
password, String pool) throws Exception;
/**
* Delete a JMS connection factory.
diff --git a/jms/src/main/java/org/apache/karaf/jms/command/CreateCommand.java
b/jms/src/main/java/org/apache/karaf/jms/command/CreateCommand.java
index 64ccf02f5d..015be0d1d9 100644
--- a/jms/src/main/java/org/apache/karaf/jms/command/CreateCommand.java
+++ b/jms/src/main/java/org/apache/karaf/jms/command/CreateCommand.java
@@ -32,11 +32,15 @@
@Option(name = "-t", aliases = { "--type" }, description = "The JMS
connection factory type (ActiveMQ, Artemis or WebsphereMQ)", required = false,
multiValued = false)
@Completion(value = StringsCompleter.class, values = { "activemq",
"artemis", "webspheremq" })
- String type = "ActiveMQ";
+ String type = "activemq";
@Option(name = "--url", description = "URL of the JMS broker. For
WebsphereMQ type, the URL is hostname/port/queuemanager/channel", required =
false, multiValued = false)
String url = "tcp://localhost:61616";
+ @Option(name = "--pool", description = "The pool mechanism to use for this
connection factory", required = false, multiValued = false)
+ @Completion(value = StringsCompleter.class, values = { "pooledjms",
"narayama", "transx" })
+ String pool = "pooledjms";
+
@Option(name = "-u", aliases = { "--username" }, description = "Username
to connect to the JMS broker", required = false, multiValued = false)
String username = "karaf";
@@ -45,7 +49,7 @@
@Override
public Object execute() throws Exception {
- getJmsService().create(name, type, url, username, password);
+ getJmsService().create(name, type, url, username, password, pool);
return null;
}
diff --git a/jms/src/main/java/org/apache/karaf/jms/internal/JmsMBeanImpl.java
b/jms/src/main/java/org/apache/karaf/jms/internal/JmsMBeanImpl.java
index e3b7801eb0..5c6a7947d4 100644
--- a/jms/src/main/java/org/apache/karaf/jms/internal/JmsMBeanImpl.java
+++ b/jms/src/main/java/org/apache/karaf/jms/internal/JmsMBeanImpl.java
@@ -51,9 +51,9 @@ public void create(String name, String type, String url)
throws MBeanException {
}
@Override
- public void create(String name, String type, String url, String username,
String password) throws MBeanException {
+ public void create(String name, String type, String url, String username,
String password, String pool) throws MBeanException {
try {
- jmsService.create(name, type, url, username, password);
+ jmsService.create(name, type, url, username, password, pool);
} catch (Throwable t) {
throw new MBeanException(null, t.getMessage());
}
diff --git
a/jms/src/main/java/org/apache/karaf/jms/internal/JmsServiceImpl.java
b/jms/src/main/java/org/apache/karaf/jms/internal/JmsServiceImpl.java
index 8dcbf94922..98b209141b 100644
--- a/jms/src/main/java/org/apache/karaf/jms/internal/JmsServiceImpl.java
+++ b/jms/src/main/java/org/apache/karaf/jms/internal/JmsServiceImpl.java
@@ -51,11 +51,11 @@ public JmsServiceImpl() {
@Override
public void create(String name, String type, String url) throws Exception {
- create(name, type, url, null, null);
+ create(name, type, url, null, null, "jmspooled");
}
@Override
- public void create(String name, String type, String url, String username,
String password) throws Exception {
+ public void create(String name, String type, String url, String username,
String password, String pool) throws Exception {
if (type == null) {
throw new IllegalArgumentException("JMS connection factory type
not known");
}
@@ -71,6 +71,12 @@ public void create(String name, String type, String url,
String username, String
put(properties, ConnectionFactoryFactory.JMS_URL, url);
put(properties, ConnectionFactoryFactory.JMS_USER, username);
put(properties, ConnectionFactoryFactory.JMS_PASSWORD, password);
+ if (pool.equals("narayana")) {
+ put(properties, "pool", "narayana");
+ }
+ if (pool.equals("transx") || type.equalsIgnoreCase("activemq")) {
+ put(properties, "pool", "transx");
+ }
Configuration config =
configAdmin.createFactoryConfiguration("org.ops4j.connectionfactory", null);
config.update(properties);
}
diff --git a/manual/src/main/asciidoc/user-guide/jms.adoc
b/manual/src/main/asciidoc/user-guide/jms.adoc
index 174fa63d77..9ee93a7057 100644
--- a/manual/src/main/asciidoc/user-guide/jms.adoc
+++ b/manual/src/main/asciidoc/user-guide/jms.adoc
@@ -75,14 +75,15 @@ SYNTAX
ARGUMENTS
name
The JMS connection factory name
+ (required)
OPTIONS
-t, --type
- The JMS connection factory type (ActiveMQ or WebsphereMQ)
- (defaults to ActiveMQ)
- -u, --username
- Username to connect to the JMS broker
- (defaults to karaf)
+ The JMS connection factory type (ActiveMQ, Artemis or
WebsphereMQ)
+ (defaults to activemq)
+ --pool
+ The pool mechanism to use for this connection factory
+ (defaults to pooledjms)
--help
Display this help message
--url
@@ -91,6 +92,10 @@ OPTIONS
-p, --password
Password to connect to the JMS broker
(defaults to karaf)
+ -u, --username
+ Username to connect to the JMS broker
+ (defaults to karaf)
+
----
@@ -99,13 +104,21 @@ OPTIONS
* the `--url` option is required. It's the URL used by the JMS connection
factory to connect to the broker. If the type is `activemq`, the URL looks like
`tcp://localhost:61616`. If the type is `webspheremq`, the URL looks like
`host/port/queuemanager/channel`.
* the `-u` (`--username`) option is optional (karaf by default). In the case
of the broker requires authentication, it's the username used.
* the `-p` (`--password`) option is optional (karaf by default). In the case
of the broker requires authentication, it's the password used.
+* the `--pool` option is optional (`pooledjms` by default). It allows you to
define the pooling framework you want to use: pooledjms, narayana, transx.
+
For instance, to create a JMS connection factory for a Apache ActiveMQ broker,
you can do:
----
+karaf@root()> feature:install pax-jms-activemq
karaf@root()> jms:create -t activemq --url tcp://localhost:61616 test
----
+[NOTE]
+====
+When you use ActiveMQ, Karaf uses `transx` as connection factory pooling
framework.
+====
+
[NOTE]
====
The `jms:create` command doesn't install any feature or bundle providing the
JMS connection factory classes (and dependencies).
diff --git a/pom.xml b/pom.xml
index f5ffbd870e..ba2be3067f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -281,9 +281,9 @@
<pax.url.version>2.5.4</pax.url.version>
<pax.web.version>7.0.0</pax.web.version>
<pax.tinybundle.version>3.0.0</pax.tinybundle.version>
- <pax.jdbc.version>1.2.0</pax.jdbc.version>
- <pax.jms.version>0.3.0</pax.jms.version>
- <pax.transx.version>0.2.0</pax.transx.version>
+ <pax.jdbc.version>1.3.0</pax.jdbc.version>
+ <pax.jms.version>1.0.1</pax.jms.version>
+ <pax.transx.version>0.3.0</pax.transx.version>
<portlet-api.version>2.0</portlet-api.version>
<slf4j.version>1.7.12</slf4j.version>
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Upgrade to Pax JMS 1.0.1
> ------------------------
>
> Key: KARAF-5721
> URL: https://issues.apache.org/jira/browse/KARAF-5721
> Project: Karaf
> Issue Type: Dependency upgrade
> Components: karaf-core
> Reporter: Jean-Baptiste Onofré
> Assignee: Jean-Baptiste Onofré
> Priority: Major
> Fix For: 4.2.1
>
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)