Skip to content

Commit da752c8

Browse files
authored
Merge pull request #54 from mikecroft/master
added JMS 1.1 consumer example for JMS notifier.
2 parents ce9da2d + ae660a6 commit da752c8

File tree

5 files changed

+188
-1
lines changed

5 files changed

+188
-1
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project-shared-configuration>
3+
<!--
4+
This file contains additional configuration written by modules in the NetBeans IDE.
5+
The configuration is intended to be shared among all the users of project and
6+
therefore it is assumed to be part of version control checkout.
7+
Without this configuration present, some functionality in the IDE may be limited or fail altogether.
8+
-->
9+
<properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
10+
<!--
11+
Properties that influence various parts of the IDE, especially code formatting and the like.
12+
You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
13+
That way multiple projects can share the same settings (useful for formatting rules for example).
14+
Any value defined here will override the pom.xml file value but is only applicable to the current project.
15+
-->
16+
<org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>1.7</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>
17+
<org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>gfv3ee6</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>
18+
</properties>
19+
</project-shared-configuration>
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<parent>
5+
<artifactId>notification-service-examples</artifactId>
6+
<groupId>fish.payara.examples</groupId>
7+
<version>1.0-SNAPSHOT</version>
8+
</parent>
9+
10+
<groupId>fish.payara.examples</groupId>
11+
<artifactId>JMS11NotificationConsumer</artifactId>
12+
<version>1.0-SNAPSHOT</version>
13+
<packaging>ejb</packaging>
14+
15+
<name>JMS11NotificationConsumer</name>
16+
17+
<properties>
18+
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
19+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
20+
</properties>
21+
22+
<dependencies>
23+
<dependency>
24+
<groupId>javax</groupId>
25+
<artifactId>javaee-api</artifactId>
26+
<version>7.0</version>
27+
<scope>provided</scope>
28+
</dependency>
29+
</dependencies>
30+
31+
<build>
32+
<plugins>
33+
<plugin>
34+
<groupId>org.apache.maven.plugins</groupId>
35+
<artifactId>maven-compiler-plugin</artifactId>
36+
<version>3.1</version>
37+
<configuration>
38+
<source>1.7</source>
39+
<target>1.7</target>
40+
<compilerArguments>
41+
<endorseddirs>${endorsed.dir}</endorseddirs>
42+
</compilerArguments>
43+
</configuration>
44+
</plugin>
45+
<plugin>
46+
<groupId>org.apache.maven.plugins</groupId>
47+
<artifactId>maven-ejb-plugin</artifactId>
48+
<version>2.3</version>
49+
<configuration>
50+
<ejbVersion>3.1</ejbVersion>
51+
</configuration>
52+
</plugin>
53+
<plugin>
54+
<groupId>org.apache.maven.plugins</groupId>
55+
<artifactId>maven-dependency-plugin</artifactId>
56+
<version>2.6</version>
57+
<executions>
58+
<execution>
59+
<phase>validate</phase>
60+
<goals>
61+
<goal>copy</goal>
62+
</goals>
63+
<configuration>
64+
<outputDirectory>${endorsed.dir}</outputDirectory>
65+
<silent>true</silent>
66+
<artifactItems>
67+
<artifactItem>
68+
<groupId>javax</groupId>
69+
<artifactId>javaee-endorsed-api</artifactId>
70+
<version>7.0</version>
71+
<type>jar</type>
72+
</artifactItem>
73+
</artifactItems>
74+
</configuration>
75+
</execution>
76+
</executions>
77+
</plugin>
78+
</plugins>
79+
</build>
80+
81+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*
2+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3+
*
4+
* Copyright (c) [2017] Payara Foundation and/or its affiliates. All rights reserved.
5+
*
6+
* The contents of this file are subject to the terms of either the GNU
7+
* General Public License Version 2 only ("GPL") or the Common Development
8+
* and Distribution License("CDDL") (collectively, the "License"). You
9+
* may not use this file except in compliance with the License. You can
10+
* obtain a copy of the License at
11+
* https://github.com/payara/Payara/blob/master/LICENSE.txt
12+
* See the License for the specific
13+
* language governing permissions and limitations under the License.
14+
*
15+
* When distributing the software, include this License Header Notice in each
16+
* file and include the License file at glassfish/legal/LICENSE.txt.
17+
*
18+
* GPL Classpath Exception:
19+
* The Payara Foundation designates this particular file as subject to the "Classpath"
20+
* exception as provided by the Payara Foundation in the GPL Version 2 section of the License
21+
* file that accompanied this code.
22+
*
23+
* Modifications:
24+
* If applicable, add the following below the License Header, with the fields
25+
* enclosed by brackets [] replaced by your own identifying information:
26+
* "Portions Copyright [year] [name of copyright owner]"
27+
*
28+
* Contributor(s):
29+
* If you wish your version of this file to be governed by only the CDDL or
30+
* only the GPL Version 2, indicate your decision by adding "[Contributor]
31+
* elects to include this software in this distribution under the [CDDL or GPL
32+
* Version 2] license." If you don't indicate a single choice of license, a
33+
* recipient has the option to distribute your version of this file under
34+
* either the CDDL, the GPL Version 2 or to extend the choice of license to
35+
* its licensees as provided above. However, if you add GPL Version 2 code
36+
* and therefore, elected the GPL Version 2 license, then the option applies
37+
* only if the new code is made subject to such option by the copyright
38+
* holder.
39+
*/
40+
41+
package fish.payara.examples.jms11notificationconsumer;
42+
43+
44+
import java.util.logging.Level;
45+
import java.util.logging.Logger;
46+
import javax.ejb.ActivationConfigProperty;
47+
import javax.ejb.MessageDriven;
48+
import javax.jms.Message;
49+
import javax.jms.MessageListener;
50+
import javax.jms.TextMessage;
51+
52+
/**
53+
*
54+
* @author Mike Croft
55+
*/
56+
@MessageDriven(activationConfig = {
57+
@ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "jms/notifierQueue"),
58+
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
59+
@ActivationConfigProperty(propertyName = "destination", propertyValue = "notifierQueue"),
60+
@ActivationConfigProperty(propertyName = "resourceAdapter", propertyValue = "activemq-rar-5.14.5")
61+
62+
})
63+
public class JMS11NotificationConsumer implements MessageListener {
64+
65+
public JMS11NotificationConsumer() {
66+
}
67+
68+
@Override
69+
public void onMessage(Message message) {
70+
try {
71+
Thread.sleep(1000L);
72+
73+
// JMS 1.1 for ActiveMQ
74+
if (message instanceof TextMessage) {
75+
TextMessage txtMsg = (TextMessage) message;
76+
System.out.println("Read Message: " + txtMsg.getText());
77+
}
78+
79+
} catch (Exception ex) {
80+
Logger.getLogger(JMS11NotificationConsumer.class.getName()).log(Level.SEVERE, null, ex);
81+
}
82+
}
83+
84+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Manifest-Version: 1.0
2+

payara-services/notification-service-examples/pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212
<name>Notification Service Examples</name>
1313
<modules>
1414
<module>JMSNotificationConsumer</module>
15-
</modules>
15+
<module>JMS11NotificationConsumer</module>
16+
</modules>
1617
</project>

0 commit comments

Comments
 (0)