From 447422604c4d48b55c128a7a4ce0a28598e6f588 Mon Sep 17 00:00:00 2001 From: Justin Bertram Date: Tue, 14 Sep 2021 22:20:18 -0500 Subject: [PATCH] ARTEMIS-3484 flesh out Jakarta Messaging support Back in version 2.17.0 we began to provide Maven artifacts for Jakarta Messaging client resources. This commit expands that support in the following ways: - Distribute a Jakarta Messaging 3.0 client with the broker (in the 'lib/client' directory alongside the JMS client. - Update documentation. - Add example using the Jakarta Messaging client. - Update Artemis CLI to use core instead of JMS as it was causing conflicts with the new Jarkarta Messaging client. - Add example to build Jarkarta Messaging version of the JCA RA for deployment into Jakarta EE 9 application servers. --- artemis-distribution/pom.xml | 7 +- .../src/main/assembly/dep.xml | 14 +- .../src/test/scripts/run-examples.sh | 1 + .../src/test/scripts/run-standard-examples.sh | 1 + artemis-jakarta-client-all/pom.xml | 136 ++++++++ artemis-maven-plugin/pom.xml | 6 +- .../artemis/maven/ArtemisCLIPlugin.java | 9 +- docs/user-manual/en/architecture.md | 42 ++- docs/user-manual/en/filter-expressions.md | 37 +- docs/user-manual/en/messaging-concepts.md | 27 +- .../en/protocols-interoperability.md | 5 +- docs/user-manual/en/using-jms.md | 20 +- docs/user-manual/en/versions.md | 1 + examples/features/standard/pom.xml | 1 + .../features/standard/queue-jakarta/pom.xml | 111 ++++++ .../features/standard/queue-jakarta/readme.md | 11 + .../artemis/jms/example/QueueExample.java | 83 +++++ .../src/main/resources/jndi.properties | 20 ++ .../artemis-jakarta-ra-rar/pom.xml | 136 ++++++++ .../src/main/resources/ra.xml | 315 ++++++++++++++++++ examples/features/sub-modules/pom.xml | 1 + pom.xml | 1 + tests/smoke-tests/pom.xml | 4 + 23 files changed, 919 insertions(+), 70 deletions(-) create mode 100644 artemis-jakarta-client-all/pom.xml create mode 100644 examples/features/standard/queue-jakarta/pom.xml create mode 100644 examples/features/standard/queue-jakarta/readme.md create mode 100644 examples/features/standard/queue-jakarta/src/main/java/org/apache/activemq/artemis/jms/example/QueueExample.java create mode 100644 examples/features/standard/queue-jakarta/src/main/resources/jndi.properties create mode 100644 examples/features/sub-modules/artemis-jakarta-ra-rar/pom.xml create mode 100644 examples/features/sub-modules/artemis-jakarta-ra-rar/src/main/resources/ra.xml diff --git a/artemis-distribution/pom.xml b/artemis-distribution/pom.xml index 23a6181ad1..90506ebd84 100644 --- a/artemis-distribution/pom.xml +++ b/artemis-distribution/pom.xml @@ -42,6 +42,11 @@ artemis-jms-client-all ${project.version} + + org.apache.activemq + artemis-jakarta-client-all + ${project.version} + org.apache.activemq artemis-boot @@ -215,7 +220,7 @@ ${project.version} war - + commons-beanutils commons-beanutils diff --git a/artemis-distribution/src/main/assembly/dep.xml b/artemis-distribution/src/main/assembly/dep.xml index f4d240fe00..62ef8c3456 100644 --- a/artemis-distribution/src/main/assembly/dep.xml +++ b/artemis-distribution/src/main/assembly/dep.xml @@ -124,6 +124,16 @@ false false + + 0755 + 0644 + + org.apache.activemq:artemis-jakarta-client-all + + lib/client + false + false + @@ -163,7 +173,7 @@ 0755 0644 - + @@ -198,7 +208,7 @@ 0755 0644 - + diff --git a/artemis-distribution/src/test/scripts/run-examples.sh b/artemis-distribution/src/test/scripts/run-examples.sh index e5e09f72c4..38757fb053 100755 --- a/artemis-distribution/src/test/scripts/run-examples.sh +++ b/artemis-distribution/src/test/scripts/run-examples.sh @@ -69,6 +69,7 @@ cd paging; mvn verify; cd .. cd pre-acknowledge; mvn verify; cd .. cd producer-rate-limit; mvn verify; cd .. cd queue; mvn verify; cd .. +cd queue-jakarta; mvn verify; cd .. cd queue-requestor; mvn verify; cd .. cd queue-selector; mvn verify; cd .. cd reattach-node; mvn verify; cd .. diff --git a/artemis-distribution/src/test/scripts/run-standard-examples.sh b/artemis-distribution/src/test/scripts/run-standard-examples.sh index 85cea6f3a4..0b32e243aa 100755 --- a/artemis-distribution/src/test/scripts/run-standard-examples.sh +++ b/artemis-distribution/src/test/scripts/run-standard-examples.sh @@ -72,6 +72,7 @@ cd paging; mvn verify; cd .. cd pre-acknowledge; mvn verify; cd .. cd producer-rate-limit; mvn verify; cd .. cd queue; mvn verify; cd .. +cd queue-jakarta; mvn verify; cd .. cd queue-requestor; mvn verify; cd .. cd queue-selector; mvn verify; cd .. cd reattach-node; mvn verify; cd .. diff --git a/artemis-jakarta-client-all/pom.xml b/artemis-jakarta-client-all/pom.xml new file mode 100644 index 0000000000..c299a47736 --- /dev/null +++ b/artemis-jakarta-client-all/pom.xml @@ -0,0 +1,136 @@ + + + 4.0.0 + + + org.apache.activemq + artemis-pom + 2.19.0-SNAPSHOT + + + artemis-jakarta-client-all + jar + ActiveMQ Artemis Jakarta Messaging Client All + + + ${project.basedir}/.. + 3.0.0 + 2.0.1 + + + + + org.apache.activemq + artemis-jakarta-client + ${project.version} + + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.3 + + + package + + shade + + + true + true + + + *:* + + INSTALL.html + LICENSE + README + META-INF/*.SF + META-INF/*.DSA + META-INF/*.RSA + META-INF/ASL2.0 + META-INF/DEPENDENCIES.txt + META-INF/LICENSE.txt + META-INF/NOTICE.txt + overview.html + + + + org.jgroups:jgroups + + org/jgroups/** + jg-magic-map.xml + jg-protocol-ids.xml + *.properties + *.xsd + + + + + + META-INF/DEPENDENCIES + + + false + + + .txt + features.xml + + + + + + org.apache.activemq + org.apache.activemq + + + org.apache.geronimo + org.apache.activemq.artemis.shaded.org.apache.geronimo + + + com.google + org.apache.activemq.artemis.shaded.com.google + + + org.apache.johnzon + org.apache.activemq.artemis.shaded.org.apache.johnzon + + + org.apache.commons + org.apache.activemq.artemis.shaded.org.apache.commons + + + org.jboss + org.apache.activemq.artemis.shaded.org.jboss + + + org.jgroups + org.apache.activemq.artemis.shaded.org.jgroups + + + + + + + + + diff --git a/artemis-maven-plugin/pom.xml b/artemis-maven-plugin/pom.xml index 72921b173c..22fa7d614c 100644 --- a/artemis-maven-plugin/pom.xml +++ b/artemis-maven-plugin/pom.xml @@ -64,7 +64,7 @@ org.apache.activemq - artemis-jms-client + artemis-core-client ${project.version} @@ -72,10 +72,6 @@ artemis-cli ${project.version} - - jakarta.jms - jakarta.jms-api - org.apache.maven.plugin-tools maven-plugin-annotations diff --git a/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisCLIPlugin.java b/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisCLIPlugin.java index 0e6d288b78..7f18f389f4 100644 --- a/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisCLIPlugin.java +++ b/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisCLIPlugin.java @@ -18,9 +18,10 @@ package org.apache.activemq.artemis.maven; import java.io.File; +import org.apache.activemq.artemis.api.core.client.ActiveMQClient; +import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.boot.Artemis; import org.apache.activemq.artemis.cli.commands.Run; -import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugin.descriptor.PluginDescriptor; @@ -105,11 +106,11 @@ public class ArtemisCLIPlugin extends ArtemisAbstractPlugin { if (testURI != null) { long timeout = System.currentTimeMillis() + spawnTimeout; while (System.currentTimeMillis() <= timeout) { - try (ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(testURI)) { + try (ServerLocator locator = ActiveMQClient.createServerLocator(testURI)) { if (testUser != null && testPassword != null) { - cf.createConnection(testUser, testPassword).close(); + locator.createSessionFactory().createSession(testUser, testPassword, false, false, false, false, 0).close(); } else { - cf.createConnection().close(); + locator.createSessionFactory().createSession().close(); } getLog().info("Server started"); } catch (Exception e) { diff --git a/docs/user-manual/en/architecture.md b/docs/user-manual/en/architecture.md index 6a73a64cab..b7ea7a4c44 100644 --- a/docs/user-manual/en/architecture.md +++ b/docs/user-manual/en/architecture.md @@ -12,14 +12,20 @@ persistence (although JDBC is still an option if necessary). Apache ActiveMQ Artemis clients, potentially on different physical machines, interact with the Apache ActiveMQ Artemis broker. Apache ActiveMQ Artemis -currently ships two API implementations for messaging at the client side: +currently ships three API implementations for messaging at the client side: 1. Core client API. This is a simple intuitive Java API that is aligned with the Artemis internal Core. Allowing more control of broker objects (e.g - direct creation of addresses and queues). The Core API also offers a full set - of messaging functionality without some of the complexities of JMS. + direct creation of addresses and queues). The Core API also offers a full + set of messaging functionality without some of the complexities of JMS. 2. JMS 2.0 client API. The standard JMS API is available at the client side. + This client is also compliant with the Jakarta Messaging 2.0 specification. + +3. Jakarta Messaging 3.0 client API. This is essentially the same as the JMS + 2.0 API. The only difference is the package names use `jakarta` insead of + `javax`. This difference was introduced due to the move from Oracle's + Java EE to Eclipse's Jakarta EE. Apache ActiveMQ Artemis also provides different protocol implementations on the server so you can use respective clients for these protocols: @@ -79,31 +85,31 @@ instantiate and embed brokers in your own application. Read more about [embedding Apache ActiveMQ Artemis](embedding-activemq.md). -## Integrated with a Java EE application server +## Integrated with a Java/Jakarta EE application server Apache ActiveMQ Artemis provides its own fully functional Java Connector Architecture (JCA) adaptor which enables it to be integrated easily into any -Java EE compliant application server or servlet engine. +Java/Jakarta EE (henceforth just "EE") compliant application server or servlet +engine. -Java EE application servers provide Message Driven Beans (MDBs), which are a -special type of Enterprise Java Beans (EJBs) that can process messages from -sources such as JMS systems or mail systems. +EE application servers provide Message Driven Beans (MDBs), which are a special +type of Enterprise Java Beans (EJBs) that can process messages from sources +such as JMS systems or mail systems. Probably the most common use of an MDB is to consume messages from a JMS messaging system. -According to the Java EE specification, a Java EE application server uses a JCA -adapter to integrate with a JMS messaging system so it can consume messages for -MDBs. +According to the EE specification an application server uses a JCA adapter to +integrate with a JMS messaging system so it can consume messages for MDBs. -However, the JCA adapter is not only used by the Java EE application server for +However, the JCA adapter is not only used by the EE application server for *consuming* messages via MDBs, it is also used when sending message to the JMS messaging system e.g. from inside an EJB or servlet. -When integrating with a JMS messaging system from inside a Java EE application +When integrating with a JMS messaging system from inside an EE application server it is always recommended that this is done via a JCA adaptor. In fact, communicating with a JMS messaging system directly, without using JCA would be -illegal according to the Java EE specification. +illegal according to the EE specification. The application server's JCA service provides extra functionality such as connection pooling and automatic transaction enlistment, which are desirable @@ -113,10 +119,10 @@ JCA adapter, but this is not recommended since you will not be able to take advantage of the JCA features, such as caching of JMS sessions, which can result in poor performance. -Figure 3.2 below shows a Java EE application server integrating with a Apache -ActiveMQ Artemis server via the Apache ActiveMQ Artemis JCA adaptor. Note that -all communication between EJB sessions or entity beans and Message Driven beans -go through the adaptor and not directly to Apache ActiveMQ Artemis. +Figure 3.2 below shows an application server integrating with a Apache ActiveMQ +Artemis server via the Apache ActiveMQ Artemis JCA adaptor. Note that all +communication between EJB sessions or entity beans and Message Driven beans go +through the adaptor and not directly to Apache ActiveMQ Artemis. The large arrow with the prohibited sign shows an EJB session bean talking directly to the Apache ActiveMQ Artemis server. This is not recommended as diff --git a/docs/user-manual/en/filter-expressions.md b/docs/user-manual/en/filter-expressions.md index 13b3185514..cbefbb1644 100644 --- a/docs/user-manual/en/filter-expressions.md +++ b/docs/user-manual/en/filter-expressions.md @@ -3,10 +3,10 @@ Apache ActiveMQ Artemis provides a powerful filter language based on a subset of the SQL 92 expression syntax. -It is the same as the syntax used for JMS selectors, but the predefined -identifiers are different. For documentation on JMS selector syntax -please the JMS javadoc for -[javax.jms.Message](https://docs.oracle.com/javaee/7/api/javax/jms/Message.html). +It is the same as the syntax used for JMS & Jakarta Messaging selectors, but the +predefined identifiers are different. For documentation on JMS selector syntax +please the JavaDoc for [`javax.jms.Message`](https://docs.oracle.com/javaee/7/api/javax/jms/Message.html). +For the corresponding Jakarta Messaging JavaDoc see [`jakarta.jms.Message`](https://jakarta.ee/specifications/messaging/3.0/apidocs/jakarta/jms/message) Filter expressions are used in several places in Apache ActiveMQ Artemis @@ -50,19 +50,20 @@ refer to attributes of the core message in an expression: Any other identifiers used in core filter expressions will be assumed to be properties of the message. -The JMS spec states that a String property should not get converted to a -numeric when used in a selector. So for example, if a message has the `age` -property set to String `21` then the following selector should not match -it: `age > 18`. Since Apache ActiveMQ Artemis supports STOMP clients which -can only send messages with string properties, that restriction is a bit -limiting. Therefore, if you want your filter expressions to auto-convert String -properties to the appropriate number type, just prefix it with -`convert_string_expressions:`. If you changed the filter expression in the +The JMS and Jakarta Messaging specs state that a String property should not +get converted to a numeric when used in a selector. So for example, if a +message has the `age` property set to `String` `21` then the following selector +should not match it: `age > 18`. Since Apache ActiveMQ Artemis supports STOMP +clients which can only send messages with string properties, that restriction +is a bit limiting. Therefore, if you want your filter expressions to +auto-convert `String` properties to the appropriate number type, just prefix it +with `convert_string_expressions:`. If you changed the filter expression in the previous example to be `convert_string_expressions:age > 18`, then it would match the aforementioned message. -The JMS spec also states that property identifiers (and therefore the -identifiers which are valid for use in a filter expression) are an: +The JMS and Jakarta Messaging specs also state that property identifiers (and +therefore the identifiers which are valid for use in a filter expression) are +an: > unlimited-length sequence of letters and digits, the first of which must be > a letter. A letter is any character for which the method @@ -70,10 +71,10 @@ identifiers which are valid for use in a filter expression) are an: > or digit is any character for which the method `Character.isJavaLetterOrDigit` > returns `true`. -This constraint means that hyphens (i.e. `-`) cannot be used. -However, this constraint can be overcome by using the `hyphenated_props:` -prefix. For example, if a message had the `foo-bar` property set to `0` then -the filter expression `hyphenated_props:foo-bar = 0` would match it. +This constraint means that hyphens (i.e. `-`) cannot be used. However, this +constraint can be overcome by using the `hyphenated_props:` prefix. For +example, if a message had the `foo-bar` property set to `0` then the filter +expression `hyphenated_props:foo-bar = 0` would match it. ## XPath diff --git a/docs/user-manual/en/messaging-concepts.md b/docs/user-manual/en/messaging-concepts.md index 0ed6c42d26..7577eaf1aa 100644 --- a/docs/user-manual/en/messaging-concepts.md +++ b/docs/user-manual/en/messaging-concepts.md @@ -158,24 +158,27 @@ emerging standards in this space. Let's take a brief look at these: -### Java Message Service (JMS) +### JMS & Jakarta Messaging -[JMS](https://en.wikipedia.org/wiki/Java_Message_Service) is part of Oracle's -Java EE specification. It's a Java API that encapsulates both message queue and -publish-subscribe messaging patterns. JMS is a lowest common denominator -specification - i.e. it was created to encapsulate common functionality of the -already existing messaging systems that were available at the time of its -creation. +[JMS](https://en.wikipedia.org/wiki/Java_Message_Service) was historically part +of Oracle's Java EE specification. However, in 2017 control was transferred to +the Eclipse Foundation and it is now known as [Jakarta Messaging](https://jakarta.ee/specifications/messaging/) +which is part of Jakarta EE. -JMS is a very popular API and is implemented by most messaging systems. JMS is +It is a Java API that encapsulates both message queue and publish-subscribe +messaging patterns. It is a lowest common denominator specification - i.e. it +was created to encapsulate common functionality of the already existing +messaging systems that were available at the time of its creation. + +It is a very popular API and is implemented by most messaging systems. It is only available to clients running Java. -JMS does not define a standard wire format - it only defines a programmatic API -so JMS clients and servers from different vendors cannot directly interoperate +It does not define a standard wire format - it only defines a programmatic API +so clients and servers from different vendors cannot directly interoperate since each will use the vendor's own internal wire protocol. -Apache ActiveMQ Artemis provides a fully compliant [JMS 1.1 and JMS 2.0 client -implementation](using-jms.md). +Apache ActiveMQ Artemis provides client implementations which are a fully +compliant with [JMS 1.1 & 2.0 as well as Jakarta Messaging 2.0 & 3.0](using-jms.md). ### System specific APIs diff --git a/docs/user-manual/en/protocols-interoperability.md b/docs/user-manual/en/protocols-interoperability.md index 1efeba121b..b1e2c472ad 100644 --- a/docs/user-manual/en/protocols-interoperability.md +++ b/docs/user-manual/en/protocols-interoperability.md @@ -20,8 +20,9 @@ modules out of the box. The 5 modules offer support for the following protocols: #### APIs and Other Interfaces -Although JMS is a standardized API, it does not define a network protocol. The [ActiveMQ Artemis JMS 2.0 client](using-jms.md) -is implemented on top of the core protocol. We also provide a [client-side JNDI implementation](using-jms.md#jndi). +Although JMS and Jakarta Messaging are standardized APIs, they does not define a network protocol. The ActiveMQ Artemis +[JMS & Jakarta Messaging clients](using-jms.md) are implemented on top of the core protocol. We also provide a +[client-side JNDI implementation](using-jms.md#jndi). The broker also ships with a [REST messaging interface](rest.md) (not to be confused with the REST management API provided via our integration with Jolokia). diff --git a/docs/user-manual/en/using-jms.md b/docs/user-manual/en/using-jms.md index e091ffa99b..506fb14df0 100644 --- a/docs/user-manual/en/using-jms.md +++ b/docs/user-manual/en/using-jms.md @@ -1,4 +1,4 @@ -# Using JMS +# Using JMS or Jakarta Messaging Although Apache ActiveMQ Artemis provides a JMS agnostic messaging API, many users will be more comfortable using JMS. @@ -178,7 +178,8 @@ The `refreshTimeout` and `discoveryInitialWaitTimeout` properties are supported just like with `udp`. The default type for the default connection factory is of type -`javax.jms.ConnectionFactory`. This can be changed by setting the type like so +`javax.jms.ConnectionFactory`or `jakarta.jms.ConnectionFactory` depending on the +client you're using. This can be changed by setting the type like so ```properties @@ -191,14 +192,17 @@ that can be set. #### Configuration for Connection Factory Types +The interface provided will depend on whether you're using the JMS or Jakarta +Messaging client implementation. + type | interface --- |--- -CF (default) | javax.jms.ConnectionFactory -XA_CF | javax.jms.XAConnectionFactory -QUEUE_CF | javax.jms.QueueConnectionFactory -QUEUE_XA_CF | javax.jms.XAQueueConnectionFactory -TOPIC_CF | javax.jms.TopicConnectionFactory -TOPIC_XA_CF | javax.jms.XATopicConnectionFactory +CF (default) | `javax.jms.ConnectionFactory` or `jakarta.jms.ConnectionFactory` +XA_CF | `javax.jms.XAConnectionFactory`or `jakarta.jms.XAConnectionFactory` +QUEUE_CF | `javax.jms.QueueConnectionFactory`or `jakarta.jms.QueueConnectionFactory` +QUEUE_XA_CF | `javax.jms.XAQueueConnectionFactory`or `jakarta.jms.XAQueueConnectionFactory` +TOPIC_CF | `javax.jms.TopicConnectionFactory`or `jakarta.jms.TopicConnectionFactory` +TOPIC_XA_CF | `javax.jms.XATopicConnectionFactory`or `jakarta.jms.XATopicConnectionFactory` ### Destination JNDI diff --git a/docs/user-manual/en/versions.md b/docs/user-manual/en/versions.md index bc00e86a58..850fccf6ff 100644 --- a/docs/user-manual/en/versions.md +++ b/docs/user-manual/en/versions.md @@ -86,6 +86,7 @@ Highlights: - JDBC datasource property values can now be masked. - Lots of usability improvements to the Hawtio 2 based web console introduced in 2.16.0 - New management method to create a core bridge using JSON-based configuration input. +- [Jakarta Messaging 2.0 & 3.0 artifacts for Jakarta EE 8 & 9 respectively](https://blogs.apache.org/activemq/entry/activemq-artemis-embraces-jakarta-ee). ## 2.16.0 diff --git a/examples/features/standard/pom.xml b/examples/features/standard/pom.xml index 3f7f2f5eab..bb455019a2 100644 --- a/examples/features/standard/pom.xml +++ b/examples/features/standard/pom.xml @@ -84,6 +84,7 @@ under the License. pre-acknowledge producer-rate-limit queue + queue-jakarta queue-requestor queue-selector reattach-node diff --git a/examples/features/standard/queue-jakarta/pom.xml b/examples/features/standard/queue-jakarta/pom.xml new file mode 100644 index 0000000000..4d99b37f47 --- /dev/null +++ b/examples/features/standard/queue-jakarta/pom.xml @@ -0,0 +1,111 @@ + + + + + 4.0.0 + + + org.apache.activemq.examples.broker + jms-examples + 2.19.0-SNAPSHOT + + + queue-jakarta + jar + ActiveMQ Artemis Jakarta Messaging 3.0 Queue Example + + + ${project.basedir}/../../../.. + + + + + org.apache.activemq + artemis-jakarta-client-all + ${project.version} + + + + + + + org.apache.activemq + artemis-maven-plugin + + + create + + create + + + ${noServer} + + + + start + + cli + + + true + ${noServer} + tcp://localhost:61616 + + run + + + + + runClient + + runClient + + + org.apache.activemq.artemis.jms.example.QueueExample + + + + stop + + cli + + + ${noServer} + + stop + + + + + + + org.apache.activemq.examples.broker + queue-jakarta + ${project.version} + + + + + org.apache.maven.plugins + maven-clean-plugin + + + + \ No newline at end of file diff --git a/examples/features/standard/queue-jakarta/readme.md b/examples/features/standard/queue-jakarta/readme.md new file mode 100644 index 0000000000..41e01d9b51 --- /dev/null +++ b/examples/features/standard/queue-jakarta/readme.md @@ -0,0 +1,11 @@ +# Jakarta Messaging 3.0 Queue Example + +To run the example, simply type **mvn verify** from this directory, or **mvn -PnoServer verify** if you want to start and create the broker manually. + +This example shows you how to send and receive a message to a JMS Queue using ActiveMQ Artemis. + +Queues are a standard part of JMS, please consult the Jakarta Messaging 3.0 specification for full details. + +A Queue is used to send messages point to point, from a producer to a consumer. The queue guarantees message ordering between these 2 points. + +Notice this example is using pretty much a default stock configuration \ No newline at end of file diff --git a/examples/features/standard/queue-jakarta/src/main/java/org/apache/activemq/artemis/jms/example/QueueExample.java b/examples/features/standard/queue-jakarta/src/main/java/org/apache/activemq/artemis/jms/example/QueueExample.java new file mode 100644 index 0000000000..d85c5ede8d --- /dev/null +++ b/examples/features/standard/queue-jakarta/src/main/java/org/apache/activemq/artemis/jms/example/QueueExample.java @@ -0,0 +1,83 @@ +/* + * 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.artemis.jms.example; + +import jakarta.jms.Connection; +import jakarta.jms.ConnectionFactory; +import jakarta.jms.MessageConsumer; +import jakarta.jms.MessageProducer; +import jakarta.jms.Queue; +import jakarta.jms.Session; +import jakarta.jms.TextMessage; +import javax.naming.InitialContext; + +/** + * A simple JMS Queue example that creates a producer and consumer on a queue and sends then receives a message. + */ +public class QueueExample { + + public static void main(final String[] args) throws Exception { + Connection connection = null; + InitialContext initialContext = null; + try { + // Step 1. Create an initial context to perform the JNDI lookup. + initialContext = new InitialContext(); + + // Step 2. Perform a lookup on the queue + Queue queue = (Queue) initialContext.lookup("queue/exampleQueue"); + + // Step 3. Perform a lookup on the Connection Factory + ConnectionFactory cf = (ConnectionFactory) initialContext.lookup("ConnectionFactory"); + + // Step 4.Create a JMS Connection + connection = cf.createConnection(); + + // Step 5. Create a JMS Session + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + + // Step 6. Create a JMS Message Producer + MessageProducer producer = session.createProducer(queue); + + // Step 7. Create a Text Message + TextMessage message = session.createTextMessage("This is a text message"); + + System.out.println("Sent message: " + message.getText()); + + // Step 8. Send the Message + producer.send(message); + + // Step 9. Create a JMS Message Consumer + MessageConsumer messageConsumer = session.createConsumer(queue); + + // Step 10. Start the Connection + connection.start(); + + // Step 11. Receive the message + TextMessage messageReceived = (TextMessage) messageConsumer.receive(5000); + + System.out.println("Received message: " + messageReceived.getText()); + } finally { + // Step 12. Be sure to close our JMS resources! + if (initialContext != null) { + initialContext.close(); + } + if (connection != null) { + connection.close(); + } + } + } +} diff --git a/examples/features/standard/queue-jakarta/src/main/resources/jndi.properties b/examples/features/standard/queue-jakarta/src/main/resources/jndi.properties new file mode 100644 index 0000000000..93537c415a --- /dev/null +++ b/examples/features/standard/queue-jakarta/src/main/resources/jndi.properties @@ -0,0 +1,20 @@ +# 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. + +java.naming.factory.initial=org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory +connectionFactory.ConnectionFactory=tcp://localhost:61616 +queue.queue/exampleQueue=exampleQueue diff --git a/examples/features/sub-modules/artemis-jakarta-ra-rar/pom.xml b/examples/features/sub-modules/artemis-jakarta-ra-rar/pom.xml new file mode 100644 index 0000000000..7567e2ebe0 --- /dev/null +++ b/examples/features/sub-modules/artemis-jakarta-ra-rar/pom.xml @@ -0,0 +1,136 @@ + + + + + 4.0.0 + + + org.apache.activemq.examples.modules + broker-modules + 2.19.0-SNAPSHOT + + + artemis-jakarta-rar + rar + ActiveMQ Artemis Jakarta Messaging 3.0 RA + + + ${project.basedir}/../../../.. + + + + + org.apache.activemq + artemis-jakarta-client + ${project.version} + + + org.apache.activemq + artemis-core-client + + + org.apache.activemq + artemis-jakarta-client + + + jakarta.jms + jakarta.jms-api + + + jakarta.json + jakarta.json-api + + + org.apache.geronimo.specs + geronimo-ejb_3.0_spec + + + + + org.apache.activemq + artemis-jakarta-ra + ${project.version} + + + jakarta.transaction + jakarta.transaction-api + + + jakarta.jms + jakarta.jms-api + + + + + org.apache.activemq + artemis-jakarta-server + ${project.version} + + + jakarta.transaction + jakarta.transaction-api + + + jakarta.jms + jakarta.jms-api + + + jakarta.json + jakarta.json-api + + + + + org.apache.activemq + artemis-core-client + ${project.version} + + + org.apache.activemq + artemis-core-client + + + jakarta.json + jakarta.json-api + + + + + io.netty + netty-all + + + + + + + org.apache.maven.plugins + maven-rar-plugin + + src/main/resources/ra.xml + + + + org.apache.maven.plugins + maven-clean-plugin + + + + \ No newline at end of file diff --git a/examples/features/sub-modules/artemis-jakarta-ra-rar/src/main/resources/ra.xml b/examples/features/sub-modules/artemis-jakarta-ra-rar/src/main/resources/ra.xml new file mode 100644 index 0000000000..943f84f6fb --- /dev/null +++ b/examples/features/sub-modules/artemis-jakarta-ra-rar/src/main/resources/ra.xml @@ -0,0 +1,315 @@ + + + + + + + ArtemisRA + ActiveMQ Artemis Resource Adapter + Apache Software Foundation + Jakarta Messaging 3.0 Server + 1.0 + + + + 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. + + true + + + + org.apache.activemq.artemis.ra.ActiveMQResourceAdapter + + + The transport type. Multiple connectors can be configured by using a comma separated list, + i.e. org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory,org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory. + + ConnectorClassName + java.lang.String + org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory + + + The transport configuration. These values must be in the form of key=val;key=val;, + if multiple connectors are used then each set must be separated by a comma i.e. host=host1;port=61616,host=host2;port=61617. + Each set of params maps to the connector classname specified. + + ConnectionParameters + java.lang.String + host=localhost,port=61616 + + + + + + + org.apache.activemq.artemis.ra.ActiveMQRAManagedConnectionFactory + + + The default session type + SessionDefaultType + java.lang.String + javax.jms.Queue + + + Whether or not to participate in a JTA transaction, this is used if the RA does not have access to the Transaction Manager + InJtaTransaction + java.lang.Boolean + true + + + Try to obtain a lock within specified number of seconds; less than or equal to 0 disable this functionality + UseTryLock + java.lang.Integer + 0 + + + org.apache.activemq.artemis.ra.ActiveMQRAConnectionFactory + org.apache.activemq.artemis.ra.ActiveMQRAConnectionFactoryImpl + javax.jms.Session + org.apache.activemq.artemis.ra.ActiveMQRASession + + XATransaction + + BasicPassword + javax.resource.spi.security.PasswordCredential + + false + + + + + + javax.jms.MessageListener + + org.apache.activemq.artemis.ra.inflow.ActiveMQActivationSpec + + destination + + + + + + + javax.jms.Queue + org.apache.activemq.artemis.jms.client.ActiveMQQueue + + Address + java.lang.String + + + + javax.jms.Topic + org.apache.activemq.artemis.jms.client.ActiveMQTopic + + Address + java.lang.String + + + + javax.jms.ConnectionFactory + org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory + + BrokerURL + java.lang.String + + + + javax.jms.XAConnectionFactory + org.apache.activemq.artemis.jms.client.ActiveMQXAConnectionFactory + + BrokerURL + java.lang.String + + + + diff --git a/examples/features/sub-modules/pom.xml b/examples/features/sub-modules/pom.xml index fe82cc637f..6c08236b10 100644 --- a/examples/features/sub-modules/pom.xml +++ b/examples/features/sub-modules/pom.xml @@ -49,6 +49,7 @@ under the License. release + artemis-jakarta-ra-rar artemis-ra-rar inter-broker-bridge tomcat diff --git a/pom.xml b/pom.xml index d9f7e4299d..3577ee6aab 100644 --- a/pom.xml +++ b/pom.xml @@ -48,6 +48,7 @@ artemis-jms-client-all artemis-jms-client-osgi artemis-jakarta-client + artemis-jakarta-client-all artemis-jms-server artemis-jakarta-server artemis-journal diff --git a/tests/smoke-tests/pom.xml b/tests/smoke-tests/pom.xml index 819d2de55c..fec613e12b 100644 --- a/tests/smoke-tests/pom.xml +++ b/tests/smoke-tests/pom.xml @@ -53,6 +53,10 @@ org.apache.activemq artemis-jms-client-all + + org.apache.activemq + artemis-jakarta-client-all +