diff --git a/payara-services/notification-service-examples/JMS11NotificationConsumer/nb-configuration.xml b/payara-services/notification-service-examples/JMS11NotificationConsumer/nb-configuration.xml new file mode 100644 index 00000000..3006372c --- /dev/null +++ b/payara-services/notification-service-examples/JMS11NotificationConsumer/nb-configuration.xml @@ -0,0 +1,19 @@ + + + + + + 1.7 + gfv3ee6 + + diff --git a/payara-services/notification-service-examples/JMS11NotificationConsumer/pom.xml b/payara-services/notification-service-examples/JMS11NotificationConsumer/pom.xml new file mode 100644 index 00000000..f0b8551d --- /dev/null +++ b/payara-services/notification-service-examples/JMS11NotificationConsumer/pom.xml @@ -0,0 +1,81 @@ + + + 4.0.0 + + notification-service-examples + fish.payara.examples + 1.0-SNAPSHOT + + + fish.payara.examples + JMS11NotificationConsumer + 1.0-SNAPSHOT + ejb + + JMS11NotificationConsumer + + + ${project.build.directory}/endorsed + UTF-8 + + + + + javax + javaee-api + 7.0 + provided + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 1.7 + 1.7 + + ${endorsed.dir} + + + + + org.apache.maven.plugins + maven-ejb-plugin + 2.3 + + 3.1 + + + + org.apache.maven.plugins + maven-dependency-plugin + 2.6 + + + validate + + copy + + + ${endorsed.dir} + true + + + javax + javaee-endorsed-api + 7.0 + jar + + + + + + + + + + diff --git a/payara-services/notification-service-examples/JMS11NotificationConsumer/src/main/java/fish/payara/examples/jms11notificationconsumer/JMS11NotificationConsumer.java b/payara-services/notification-service-examples/JMS11NotificationConsumer/src/main/java/fish/payara/examples/jms11notificationconsumer/JMS11NotificationConsumer.java new file mode 100644 index 00000000..9a517965 --- /dev/null +++ b/payara-services/notification-service-examples/JMS11NotificationConsumer/src/main/java/fish/payara/examples/jms11notificationconsumer/JMS11NotificationConsumer.java @@ -0,0 +1,84 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) [2017] Payara Foundation and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://github.com/payara/Payara/blob/master/LICENSE.txt + * See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at glassfish/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * The Payara Foundation designates this particular file as subject to the "Classpath" + * exception as provided by the Payara Foundation in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ + +package fish.payara.examples.jms11notificationconsumer; + + +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.ejb.ActivationConfigProperty; +import javax.ejb.MessageDriven; +import javax.jms.Message; +import javax.jms.MessageListener; +import javax.jms.TextMessage; + +/** + * + * @author Mike Croft + */ +@MessageDriven(activationConfig = { + @ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "jms/notifierQueue"), + @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"), + @ActivationConfigProperty(propertyName = "destination", propertyValue = "notifierQueue"), + @ActivationConfigProperty(propertyName = "resourceAdapter", propertyValue = "activemq-rar-5.14.5") + +}) +public class JMS11NotificationConsumer implements MessageListener { + + public JMS11NotificationConsumer() { + } + + @Override + public void onMessage(Message message) { + try { + Thread.sleep(1000L); + + // JMS 1.1 for ActiveMQ + if (message instanceof TextMessage) { + TextMessage txtMsg = (TextMessage) message; + System.out.println("Read Message: " + txtMsg.getText()); + } + + } catch (Exception ex) { + Logger.getLogger(JMS11NotificationConsumer.class.getName()).log(Level.SEVERE, null, ex); + } + } + +} \ No newline at end of file diff --git a/payara-services/notification-service-examples/JMS11NotificationConsumer/src/main/resources/META-INF/MANIFEST.MF b/payara-services/notification-service-examples/JMS11NotificationConsumer/src/main/resources/META-INF/MANIFEST.MF new file mode 100644 index 00000000..59499bce --- /dev/null +++ b/payara-services/notification-service-examples/JMS11NotificationConsumer/src/main/resources/META-INF/MANIFEST.MF @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 + diff --git a/payara-services/notification-service-examples/pom.xml b/payara-services/notification-service-examples/pom.xml index e1af00b1..aef55e23 100644 --- a/payara-services/notification-service-examples/pom.xml +++ b/payara-services/notification-service-examples/pom.xml @@ -12,5 +12,6 @@ Notification Service Examples JMSNotificationConsumer - + JMS11NotificationConsumer + \ No newline at end of file