This is an automated email from the ASF dual-hosted git repository. cshannon pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/activemq.git
The following commit(s) were added to refs/heads/main by this push: new 2ee6bb0c7 [AMQ-9218] Jakarta transition module for activemq-client (#968) 2ee6bb0c7 is described below commit 2ee6bb0c794b84b9cd886e54be6ce6e833e5164c Author: Matt Pavlovich <m...@hyte.io> AuthorDate: Mon Mar 13 06:03:17 2023 -0500 [AMQ-9218] Jakarta transition module for activemq-client (#968) --- activemq-client-jakarta/pom.xml | 183 +++++++++++++++++++++ .../org/apache/activemq/jakarta/JakartaTest.java | 86 ++++++++++ activemq-client/pom.xml | 1 + pom.xml | 46 ++++-- 4 files changed, 302 insertions(+), 14 deletions(-) diff --git a/activemq-client-jakarta/pom.xml b/activemq-client-jakarta/pom.xml new file mode 100644 index 000000000..3ee72e39d --- /dev/null +++ b/activemq-client-jakarta/pom.xml @@ -0,0 +1,183 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.activemq</groupId> + <artifactId>activemq-parent</artifactId> + <version>5.18.0-SNAPSHOT</version> + </parent> + <artifactId>activemq-client-jakarta</artifactId> + <packaging>bundle</packaging> + <name>ActiveMQ :: Client Jakarta</name> + <description>Jakarta transition module for ActiveMQ Client implementation</description> + <dependencies> + <dependency> + <groupId>org.apache.activemq</groupId> + <artifactId>activemq-client</artifactId> + <scope>provided</scope> + <exclusions> + <exclusion> + <groupId>jakarta.jms</groupId> + <artifactId>jakarta.jms-api</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>jakarta.jms</groupId> + <artifactId>jakarta.jms-api</artifactId> + <version>${jakarta-jms-api-v3-version}</version> + </dependency> + <dependency> + <groupId>org.fusesource.hawtbuf</groupId> + <artifactId>hawtbuf</artifactId> + <version>${hawtbuf-version}</version> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + </dependency> + <dependency> + <groupId>javax.jmdns</groupId> + <artifactId>jmdns</artifactId> + <optional>true</optional> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>com.thoughtworks.xstream</groupId> + <artifactId>xstream</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + <build> + <plugins> + <plugin> + <artifactId>maven-dependency-plugin</artifactId> + <executions> + <execution> + <id>unpack-source</id> + <phase>initialize</phase> + <goals> + <goal>unpack</goal> + </goals> + <configuration> + <artifactItems> + <artifactItem> + <groupId>org.apache.activemq</groupId> + <artifactId>activemq-client</artifactId> + <classifier>sources</classifier> + <type>jar</type> + <outputDirectory>${project.build.directory}/copied-sources/activemq-client</outputDirectory> + <excludes>**/META-INF/**,**/zeroconf/**</excludes> + <includes>**/**</includes> + </artifactItem> + </artifactItems> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>com.google.code.maven-replacer-plugin</groupId> + <artifactId>replacer</artifactId> + <executions> + <execution> + <phase>initialize</phase> + <goals> + <goal>replace</goal> + </goals> + </execution> + </executions> + <configuration> + <includes> + <include>${project.build.directory}/copied-sources/activemq-client/**/*.java</include> + </includes> + <token>javax.jms</token> + <value>jakarta.jms</value> + <regexFlags> + <regexFlag>MULTILINE</regexFlag> + </regexFlags> + </configuration> + </plugin> + <plugin> + <artifactId>maven-resources-plugin</artifactId> + <executions> + <execution> + <id>copy-resources</id> + <phase>generate-sources</phase> + <goals> + <goal>copy-resources</goal> + </goals> + <configuration> + <outputDirectory>${project.build.directory}/generated-sources</outputDirectory> + <resources> + <resource> + <directory>${project.build.directory}/copied-sources/activemq-client</directory> + </resource> + </resources> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <executions> + <execution> + <id>add-source</id> + <phase>generate-sources</phase> + <goals> + <goal>add-source</goal> + </goals> + <configuration> + <sources> + <source>${project.build.directory}/generated-sources</source> + </sources> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <extensions>true</extensions> + <inherited>true</inherited> + <configuration> + <instructions> + <Import-Package> + !java.*, + !com.google.errorprone.annotations, + !com.google.errorprone.annotations.concurrent, + com.thoughtworks.xstream.*;resolution:="optional", + * + </Import-Package> + <Private-Package> + com.google.errorprone.annotations, + com.google.errorprone.annotations.concurrent + </Private-Package> + <_noee>true</_noee> + </instructions> + </configuration> + </plugin> + </plugins> + </build> +</project> 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 000000000..fde88cd14 --- /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 473de04b0..29f231d5d 100644 --- a/activemq-client/pom.xml +++ b/activemq-client/pom.xml @@ -31,6 +31,7 @@ <description>The ActiveMQ Client implementation</description> <properties> + <maven.source.skip>false</maven.source.skip> <surefire.argLine>-Xmx512M</surefire.argLine> </properties> diff --git a/pom.xml b/pom.xml index a26b7bad9..ea7f65d44 100644 --- a/pom.xml +++ b/pom.xml @@ -68,6 +68,8 @@ <httpcore-version>4.4.16</httpcore-version> <insight-version>1.2.0.Beta4</insight-version> <jackson-version>2.14.2</jackson-version> + <jakarta-jms-api-version>2.0.3</jakarta-jms-api-version> + <jakarta-jms-api-v3-version>3.1.0</jakarta-jms-api-v3-version> <jasypt-version>1.9.3</jasypt-version> <jaxb-bundle-version>2.3.2_1</jaxb-bundle-version> <jetty9-version>9.4.50.v20221201</jetty9-version> @@ -141,6 +143,7 @@ <cobertura-maven-plugin-version>2.7</cobertura-maven-plugin-version> <taglist-maven-plugin-version>3.0.0</taglist-maven-plugin-version> <build-helper-maven-plugin-version>3.3.0</build-helper-maven-plugin-version> + <replacer-maven-plugin-version>1.5.3</replacer-maven-plugin-version> <apache-rat-plugin-version>0.15</apache-rat-plugin-version> <tools-maven-plugin-version>1.4</tools-maven-plugin-version> <depends-maven-plugin-version>1.4.0</depends-maven-plugin-version> @@ -159,6 +162,7 @@ <activemq.osgi.dynamic.import /> <activemq.osgi.symbolic.name>${project.groupId}.${project.artifactId}</activemq.osgi.symbolic.name> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <maven.source.skip>true</maven.source.skip> </properties> <url>http://activemq.apache.org</url> @@ -202,6 +206,7 @@ <modules> <module>activemq-openwire-generator</module> <module>activemq-client</module> + <module>activemq-client-jakarta</module> <module>activemq-openwire-legacy</module> <module>activemq-broker</module> <module>activemq-stomp</module> @@ -451,7 +456,7 @@ <dependency> <groupId>jakarta.jms</groupId> <artifactId>jakarta.jms-api</artifactId> - <version>2.0.3</version> + <version>${jakarta-jms-api-version}</version> </dependency> <dependency> @@ -1132,6 +1137,11 @@ <tagNameFormat>activemq-@{project.version}</tagNameFormat> </configuration> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-source-plugin</artifactId> + <version>${maven-source-plugin-version}</version> + </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> @@ -1215,6 +1225,11 @@ <artifactId>maven-plugin-plugin</artifactId> <version>${maven-plugin-plugin-version}</version> </plugin> + <plugin> + <groupId>com.google.code.maven-replacer-plugin</groupId> + <artifactId>replacer</artifactId> + <version>${replacer-maven-plugin-version}</version> + </plugin> <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.--> <plugin> @@ -1461,6 +1476,19 @@ </execution> </executions> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-source-plugin</artifactId> + <version>${maven-source-plugin-version}</version> + <executions> + <execution> + <id>attach-sources</id> + <goals> + <goal>jar</goal> + </goals> + </execution> + </executions> + </plugin> </plugins> </build> <reporting> @@ -1556,22 +1584,12 @@ </profile> <profile> <id>deploy</id> + <properties> + <maven.source.skip>false</maven.source.skip> + </properties> <build> <defaultGoal>deploy</defaultGoal> <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-source-plugin</artifactId> - <version>${maven-source-plugin-version}</version> - <executions> - <execution> - <id>attach-sources</id> - <goals> - <goal>jar</goal> - </goals> - </execution> - </executions> - </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId>