diff --git a/rules/rules-reviewed/quarkus/java-ee/jms-to-reactive-quarkus.windup.xml b/rules/rules-reviewed/quarkus/java-ee/jms-to-reactive-quarkus.windup.xml new file mode 100755 index 000000000..08e09d2ac --- /dev/null +++ b/rules/rules-reviewed/quarkus/java-ee/jms-to-reactive-quarkus.windup.xml @@ -0,0 +1,215 @@ + + + + + This ruleset gives hints to migrate from JMS to a reactive messaging model in Quarkus. + + + + + + + + + + + + + + + + + + + + + + + + + + io.quarkus + quarkus-smallrye-reactive-messaging + + + ``` + + Take a look at the Smallrye Reactive Connectors link below to know more about how to interact with different technologies (AMQP, Apache Camel, ...) + ]]> + + + + + + + + + + + ANNOTATION + + + ANNOTATION + + + + + + + + + + + + + + + + + ANNOTATION + + + + ANNOTATION + + + + + + + + + + + + + + + + + + + FIELD_DECLARATION + + + FIELD_DECLARATION + + + + + + + queueEmitter; + ``` + ]]> + + + + + + + + + + + FIELD_DECLARATION + + + FIELD_DECLARATION + + + + + + + topicEmitter; + ``` + ]]> + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/rules/rules-reviewed/quarkus/java-ee/tests/cdi-to-quarkus.windup.test.xml b/rules/rules-reviewed/quarkus/java-ee/tests/cdi-to-quarkus.windup.test.xml index 25f735022..df7b2d8c1 100644 --- a/rules/rules-reviewed/quarkus/java-ee/tests/cdi-to-quarkus.windup.test.xml +++ b/rules/rules-reviewed/quarkus/java-ee/tests/cdi-to-quarkus.windup.test.xml @@ -71,7 +71,7 @@ - + diff --git a/rules/rules-reviewed/quarkus/java-ee/tests/data/jms-to-reactive-quarkus/HelloWorldMDBServletClient.java b/rules/rules-reviewed/quarkus/java-ee/tests/data/jms-to-reactive-quarkus/HelloWorldMDBServletClient.java new file mode 100644 index 000000000..095d3097a --- /dev/null +++ b/rules/rules-reviewed/quarkus/java-ee/tests/data/jms-to-reactive-quarkus/HelloWorldMDBServletClient.java @@ -0,0 +1,111 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2015, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.as.quickstarts.servlet; + +import java.io.IOException; +import java.io.PrintWriter; + +import javax.annotation.Resource; +import javax.inject.Inject; +import javax.jms.Destination; +import javax.jms.JMSContext; +import javax.jms.JMSDestinationDefinition; +import javax.jms.JMSDestinationDefinitions; +import javax.jms.Queue; +import javax.jms.Topic; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * Definition of the two JMS destinations used by the quickstart + * (one queue and one topic). + */ +@JMSDestinationDefinitions( + value = { + @JMSDestinationDefinition( + name = "java:/queue/HELLOWORLDMDBQueue", + interfaceName = "javax.jms.Queue", + destinationName = "HelloWorldMDBQueue" + ), + @JMSDestinationDefinition( + name = "java:/topic/HELLOWORLDMDBTopic", + interfaceName = "javax.jms.Topic", + destinationName = "HelloWorldMDBTopic" + ) + } +) + +/** + *

+ * A simple servlet 3 as client that sends several messages to a queue or a topic. + *

+ * + *

+ * The servlet is registered and mapped to /HelloWorldMDBServletClient using the {@linkplain WebServlet + * @HttpServlet}. + *

+ * + * @author Serge Pagop (spagop@redhat.com) + * + */ +@WebServlet("/HelloWorldMDBServletClient") +public class HelloWorldMDBServletClient extends HttpServlet { + + private static final long serialVersionUID = -8314035702649252239L; + + private static final int MSG_COUNT = 5; + + @Inject + private JMSContext context; + + @Resource(lookup = "java:/queue/HELLOWORLDMDBQueue") + private Queue queue; + + @Resource(lookup = "java:/topic/HELLOWORLDMDBTopic") + private Topic topic; + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + resp.setContentType("text/html"); + PrintWriter out = resp.getWriter(); + out.write("

Quickstart: Example demonstrates the use of JMS 2.0 and EJB 3.2 Message-Driven Bean in JBoss EAP.

"); + try { + boolean useTopic = req.getParameterMap().keySet().contains("topic"); + final Destination destination = useTopic ? topic : queue; + + out.write("

Sending messages to " + destination + "

"); + out.write("

The following messages will be sent to the destination:

"); + for (int i = 0; i < MSG_COUNT; i++) { + String text = "This is message " + (i + 1); + context.createProducer().send(destination, text); + out.write("Message (" + i + "): " + text + "
"); + } + out.write("

Go to your JBoss EAP server console or server log to see the result of messages processing.

"); + } finally { + if (out != null) { + out.close(); + } + } + } + + protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + doGet(req, resp); + } +} diff --git a/rules/rules-reviewed/quarkus/java-ee/tests/data/jms-to-reactive-quarkus/HelloWorldQueueMDB.java b/rules/rules-reviewed/quarkus/java-ee/tests/data/jms-to-reactive-quarkus/HelloWorldQueueMDB.java new file mode 100755 index 000000000..f77db9f3b --- /dev/null +++ b/rules/rules-reviewed/quarkus/java-ee/tests/data/jms-to-reactive-quarkus/HelloWorldQueueMDB.java @@ -0,0 +1,58 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2015, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed 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.jboss.as.quickstarts.mdb; + +import java.util.logging.Logger; +import javax.ejb.ActivationConfigProperty; +import javax.ejb.MessageDriven; +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.MessageListener; +import javax.jms.TextMessage; + +/** + *

+ * A simple Message Driven Bean that asynchronously receives and processes the messages that are sent to the queue. + *

+ * + * @author Serge Pagop (spagop@redhat.com) + */ +@MessageDriven(name = "HelloWorldQueueMDB", activationConfig = { + @ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "queue/HELLOWORLDMDBQueue"), + @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"), + @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge")}) +public class HelloWorldQueueMDB implements MessageListener { + + private static final Logger LOGGER = Logger.getLogger(HelloWorldQueueMDB.class.toString()); + + /** + * @see MessageListener#onMessage(Message) + */ + public void onMessage(Message rcvMessage) { + TextMessage msg = null; + try { + if (rcvMessage instanceof TextMessage) { + msg = (TextMessage) rcvMessage; + LOGGER.info("Received Message from queue: " + msg.getText()); + } else { + LOGGER.warning("Message of wrong type: " + rcvMessage.getClass().getName()); + } + } catch (JMSException e) { + throw new RuntimeException(e); + } + } +} diff --git a/rules/rules-reviewed/quarkus/java-ee/tests/data/jms-to-reactive-quarkus/pom.xml b/rules/rules-reviewed/quarkus/java-ee/tests/data/jms-to-reactive-quarkus/pom.xml new file mode 100644 index 000000000..a8325b46d --- /dev/null +++ b/rules/rules-reviewed/quarkus/java-ee/tests/data/jms-to-reactive-quarkus/pom.xml @@ -0,0 +1,223 @@ + + + + 4.0.0 + org.jboss.eap.quickstarts + 7.4.0.GA + helloworld-mdb + war + Quickstart: helloworld-mdb + This project demonstrates a hello world Message-Driven Bean with Servlet 3.0 as client + + + + Apache License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.html + repo + + + + + 1.8 + 1.8 + + ${project.basedir} + EAP7_HOME + JBoss EAP + 7.4.0.GA + + 2.1.0 + 2.0.2.Final + 1.0.7.Final + 2.3.0.Final + + 3.0 + 8.5 + 1.2.3.Final + + UTF-8 + + + https + + + ${maven.repository.protocol}://repository.jboss.org/nexus/content/groups/public/ + + + ${maven.repository.protocol}://maven.repository.redhat.com/ga/ + + + 7.4.0.GA + + + 1.2.0.Beta1 + 20150729 + 1.7.9 + + http://rhdp-drupal.stage.redhat.com/ + false + 3.0.0.GA + 3.3.2 + + + + + true + never + + + true + never + + jboss-public-repository-group + JBoss Public Repository Group + ${maven.repository.url} + default + + + + true + never + + + true + never + + jboss-enterprise-maven-repository + JBoss Enterprise Maven Repository + ${maven.redhat.repository.url} + default + + + + + + + + org.jboss.bom + jboss-eap-jakartaee8-with-tools + ${version.server.bom} + pom + import + + + + + + jakarta.enterprise + jakarta.enterprise.cdi-api + provided + + + org.jboss.spec.javax.ejb + jboss-ejb-api_3.2_spec + provided + + + javax.jms + javax.jms-api + + + org.jboss.spec.javax.jms + jboss-jms-api_2.0_spec + provided + + + + org.jboss.spec.javax.servlet + jboss-servlet-api_4.0_spec + provided + + + org.jboss.spec.javax.annotation + jboss-annotations-api_1.3_spec + provided + + + + + + ${project.artifactId} + + + maven-war-plugin + 2.4 + + false + + + + org.wildfly.plugins + wildfly-maven-plugin + ${version.wildfly.maven.plugin} + + + + + + + + + + openshift + + + + org.apache.maven.plugins + maven-war-plugin + ${version.war.plugin} + + ROOT + + + + org.apache.maven.plugins + maven-source-plugin + + + attach-sources + none + + + + + + + + diff --git a/rules/rules-reviewed/quarkus/java-ee/tests/dependency-removal-for-quarkus.windup.test.xml b/rules/rules-reviewed/quarkus/java-ee/tests/dependency-removal-for-quarkus.windup.test.xml index 820e5d10a..35f0d75bc 100644 --- a/rules/rules-reviewed/quarkus/java-ee/tests/dependency-removal-for-quarkus.windup.test.xml +++ b/rules/rules-reviewed/quarkus/java-ee/tests/dependency-removal-for-quarkus.windup.test.xml @@ -10,7 +10,7 @@ - + diff --git a/rules/rules-reviewed/quarkus/java-ee/tests/javaee-pom-to-quarkus.windup.test.xml b/rules/rules-reviewed/quarkus/java-ee/tests/javaee-pom-to-quarkus.windup.test.xml index ab377604b..1236f4513 100644 --- a/rules/rules-reviewed/quarkus/java-ee/tests/javaee-pom-to-quarkus.windup.test.xml +++ b/rules/rules-reviewed/quarkus/java-ee/tests/javaee-pom-to-quarkus.windup.test.xml @@ -10,7 +10,7 @@ - + @@ -22,7 +22,7 @@ - + @@ -34,7 +34,7 @@ - + @@ -46,7 +46,7 @@ - + @@ -58,7 +58,7 @@ - + @@ -70,7 +70,7 @@ - + @@ -82,7 +82,7 @@ - + diff --git a/rules/rules-reviewed/quarkus/java-ee/tests/jms-to-reactive-quarkus.windup.test.xml b/rules/rules-reviewed/quarkus/java-ee/tests/jms-to-reactive-quarkus.windup.test.xml new file mode 100755 index 000000000..f15d6560b --- /dev/null +++ b/rules/rules-reviewed/quarkus/java-ee/tests/jms-to-reactive-quarkus.windup.test.xml @@ -0,0 +1,84 @@ + + + data/jms-to-reactive-quarkus + ../jms-to-reactive-quarkus.windup.xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +