From 2ee6bb0c794b84b9cd886e54be6ce6e833e5164c Mon Sep 17 00:00:00 2001 From: Matt Pavlovich Date: Mon, 13 Mar 2023 06:03:17 -0500 Subject: [PATCH] [AMQ-9218] Jakarta transition module for activemq-client (#968) --- activemq-client-jakarta/pom.xml | 183 ++++++++++++++++++ .../apache/activemq/jakarta/JakartaTest.java | 86 ++++++++ activemq-client/pom.xml | 1 + pom.xml | 46 +++-- 4 files changed, 302 insertions(+), 14 deletions(-) create mode 100644 activemq-client-jakarta/pom.xml create mode 100644 activemq-client-jakarta/src/test/java/org/apache/activemq/jakarta/JakartaTest.java diff --git a/activemq-client-jakarta/pom.xml b/activemq-client-jakarta/pom.xml new file mode 100644 index 0000000000..3ee72e39d8 --- /dev/null +++ b/activemq-client-jakarta/pom.xml @@ -0,0 +1,183 @@ + + + + 4.0.0 + + org.apache.activemq + activemq-parent + 5.18.0-SNAPSHOT + + activemq-client-jakarta + bundle + ActiveMQ :: Client Jakarta + Jakarta transition module for ActiveMQ Client implementation + + + org.apache.activemq + activemq-client + provided + + + jakarta.jms + jakarta.jms-api + + + + + jakarta.jms + jakarta.jms-api + ${jakarta-jms-api-v3-version} + + + org.fusesource.hawtbuf + hawtbuf + ${hawtbuf-version} + + + org.slf4j + slf4j-api + + + javax.jmdns + jmdns + true + provided + + + com.thoughtworks.xstream + xstream + provided + + + junit + junit + test + + + + + + maven-dependency-plugin + + + unpack-source + initialize + + unpack + + + + + org.apache.activemq + activemq-client + sources + jar + ${project.build.directory}/copied-sources/activemq-client + **/META-INF/**,**/zeroconf/** + **/** + + + + + + + + com.google.code.maven-replacer-plugin + replacer + + + initialize + + replace + + + + + + ${project.build.directory}/copied-sources/activemq-client/**/*.java + + javax.jms + jakarta.jms + + MULTILINE + + + + + maven-resources-plugin + + + copy-resources + generate-sources + + copy-resources + + + ${project.build.directory}/generated-sources + + + ${project.build.directory}/copied-sources/activemq-client + + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add-source + generate-sources + + add-source + + + + ${project.build.directory}/generated-sources + + + + + + + org.apache.felix + maven-bundle-plugin + true + true + + + + !java.*, + !com.google.errorprone.annotations, + !com.google.errorprone.annotations.concurrent, + com.thoughtworks.xstream.*;resolution:="optional", + * + + + com.google.errorprone.annotations, + com.google.errorprone.annotations.concurrent + + <_noee>true + + + + + + diff --git a/activemq-client-jakarta/src/test/java/org/apache/activemq/jakarta/JakartaTest.java b/activemq-client-jakarta/src/test/java/org/apache/activemq/jakarta/JakartaTest.java new file mode 100644 index 0000000000..fde88cd147 --- /dev/null +++ b/activemq-client-jakarta/src/test/java/org/apache/activemq/jakarta/JakartaTest.java @@ -0,0 +1,86 @@ +/** + * 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.activemq.jakarta; + +import static org.junit.Assert.*; + +import org.apache.activemq.ActiveMQConnectionFactory; +import org.junit.Ignore; +import org.junit.Test; + +import jakarta.jms.Connection; +import jakarta.jms.Destination; +import jakarta.jms.JMSException; +import jakarta.jms.Message; +import jakarta.jms.MessageConsumer; +import jakarta.jms.MessageProducer; +import jakarta.jms.Session; +import jakarta.jms.TextMessage; + +public class JakartaTest { + + @Ignore // NOTE: Remove @Ignore to test manually with local running ActiveMQ broker until we have a Jakarta-supported broker + @Test + public void testJakartaConnection() throws JMSException { + ActiveMQConnectionFactory activemqConnectionFactory = new ActiveMQConnectionFactory("admin", "admin", "tcp://localhost:61616"); + Connection connection = activemqConnectionFactory.createConnection(); + assertTrue(jakarta.jms.Connection.class.isAssignableFrom(connection.getClass())); + connection.start(); + + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + assertTrue(jakarta.jms.Session.class.isAssignableFrom(session.getClass())); + + Destination queue = session.createQueue("JAKARTA.TEST"); + assertTrue(jakarta.jms.Destination.class.isAssignableFrom(queue.getClass())); + + MessageProducer messageProducer = session.createProducer(queue); + assertTrue(jakarta.jms.MessageProducer.class.isAssignableFrom(messageProducer.getClass())); + + String messageText = "Test Jakarta API"; + TextMessage sendMessage = session.createTextMessage(messageText); + assertTrue(jakarta.jms.Message.class.isAssignableFrom(sendMessage.getClass())); + assertTrue(jakarta.jms.TextMessage.class.isAssignableFrom(sendMessage.getClass())); + + messageProducer.send(sendMessage); + + MessageConsumer messageConsumer = session.createConsumer(queue); + assertTrue(jakarta.jms.MessageConsumer.class.isAssignableFrom(messageConsumer.getClass())); + + Message recvMessage = messageConsumer.receive(5000l); + assertNotNull(recvMessage); + assertTrue(jakarta.jms.Message.class.isAssignableFrom(sendMessage.getClass())); + assertTrue(jakarta.jms.TextMessage.class.isAssignableFrom(sendMessage.getClass())); + assertEquals(messageText, TextMessage.class.cast(recvMessage).getText()); + + if(messageConsumer != null) { + try { messageConsumer.close(); } catch (JMSException e) { } + } + + if(messageProducer != null) { + try { messageProducer.close(); } catch (JMSException e) { } + } + + if(session != null) { + try { session.close(); } catch (JMSException e) { } + } + + if(connection != null) { + try { connection.close(); } catch (JMSException e) { } + } + } + +} diff --git a/activemq-client/pom.xml b/activemq-client/pom.xml index 473de04b07..29f231d5df 100644 --- a/activemq-client/pom.xml +++ b/activemq-client/pom.xml @@ -31,6 +31,7 @@ The ActiveMQ Client implementation + false -Xmx512M diff --git a/pom.xml b/pom.xml index a26b7bad92..ea7f65d44f 100644 --- a/pom.xml +++ b/pom.xml @@ -68,6 +68,8 @@ 4.4.16 1.2.0.Beta4 2.14.2 + 2.0.3 + 3.1.0 1.9.3 2.3.2_1 9.4.50.v20221201 @@ -141,6 +143,7 @@ 2.7 3.0.0 3.3.0 + 1.5.3 0.15 1.4 1.4.0 @@ -159,6 +162,7 @@ ${project.groupId}.${project.artifactId} UTF-8 + true http://activemq.apache.org @@ -202,6 +206,7 @@ activemq-openwire-generator activemq-client + activemq-client-jakarta activemq-openwire-legacy activemq-broker activemq-stomp @@ -451,7 +456,7 @@ jakarta.jms jakarta.jms-api - 2.0.3 + ${jakarta-jms-api-version} @@ -1132,6 +1137,11 @@ activemq-@{project.version} + + org.apache.maven.plugins + maven-source-plugin + ${maven-source-plugin-version} + org.apache.maven.plugins maven-surefire-plugin @@ -1215,6 +1225,11 @@ maven-plugin-plugin ${maven-plugin-plugin-version} + + com.google.code.maven-replacer-plugin + replacer + ${replacer-maven-plugin-version} + @@ -1461,6 +1476,19 @@ + + org.apache.maven.plugins + maven-source-plugin + ${maven-source-plugin-version} + + + attach-sources + + jar + + + + @@ -1556,22 +1584,12 @@ deploy + + false + deploy - - org.apache.maven.plugins - maven-source-plugin - ${maven-source-plugin-version} - - - attach-sources - - jar - - - - org.apache.maven.plugins maven-javadoc-plugin