Skip to content

Commit 398254a

Browse files
authored
Add Jakarta.JMS starter and sample app (#641)
* Add Jakarta.JMS starter and sample app * Fix up module references * Fix up artifactId
1 parent 3f6a6d6 commit 398254a

File tree

15 files changed

+1483
-0
lines changed

15 files changed

+1483
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!-- Copyright (c) 2023, Oracle and/or its affiliates. -->
3+
<!-- Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. -->
4+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
6+
<modelVersion>4.0.0</modelVersion>
7+
<parent>
8+
<groupId>org.springframework.boot</groupId>
9+
<artifactId>spring-boot-starter-parent</artifactId>
10+
<version>3.0.2</version>
11+
<relativePath/> <!-- lookup parent from repository -->
12+
</parent>
13+
<groupId>com.example</groupId>
14+
<artifactId>aqjms-jakarta-sample</artifactId>
15+
<version>0.0.1-SNAPSHOT</version>
16+
<name>aqjms-jakarta-sample</name>
17+
<description>Demo project for Spring Boot</description>
18+
<properties>
19+
<java.version>17</java.version>
20+
</properties>
21+
22+
<dependencies>
23+
<dependency>
24+
<groupId>com.oracle.database.spring</groupId>
25+
<artifactId>oracle-spring-boot-starter-aqjms</artifactId>
26+
<version>3.0.2</version>
27+
</dependency>
28+
</dependencies>
29+
30+
<build>
31+
<plugins>
32+
<plugin>
33+
<groupId>org.springframework.boot</groupId>
34+
<artifactId>spring-boot-maven-plugin</artifactId>
35+
</plugin>
36+
</plugins>
37+
</build>
38+
39+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright (c) 2023, Oracle and/or its affiliates.
2+
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
3+
4+
package com.example.aqjms;
5+
6+
import lombok.AllArgsConstructor;
7+
import lombok.Getter;
8+
import lombok.NoArgsConstructor;
9+
import lombok.Setter;
10+
import lombok.ToString;
11+
12+
@AllArgsConstructor
13+
@NoArgsConstructor
14+
@Getter
15+
@Setter
16+
@ToString
17+
public class Email {
18+
private String to;
19+
private String body;
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Copyright (c) 2023, Oracle and/or its affiliates.
2+
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
3+
4+
package com.example.aqjms;
5+
6+
import jakarta.jms.ConnectionFactory;
7+
8+
import org.springframework.boot.SpringApplication;
9+
import org.springframework.boot.autoconfigure.SpringBootApplication;
10+
import org.springframework.boot.autoconfigure.jms.DefaultJmsListenerContainerFactoryConfigurer;
11+
import org.springframework.context.ConfigurableApplicationContext;
12+
import org.springframework.context.annotation.Bean;
13+
import org.springframework.jms.annotation.EnableJms;
14+
import org.springframework.jms.config.DefaultJmsListenerContainerFactory;
15+
import org.springframework.jms.config.JmsListenerContainerFactory;
16+
import org.springframework.jms.core.JmsTemplate;
17+
import org.springframework.jms.support.converter.MappingJackson2MessageConverter;
18+
import org.springframework.jms.support.converter.MessageConverter;
19+
import org.springframework.jms.support.converter.MessageType;
20+
21+
@SpringBootApplication
22+
@EnableJms
23+
public class JmsSampleApplication {
24+
25+
@Bean
26+
public JmsListenerContainerFactory<?> myFactory(ConnectionFactory connectionFactory,
27+
DefaultJmsListenerContainerFactoryConfigurer configurer) {
28+
DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
29+
// This provides all boot's default to this factory, including the message converter
30+
configurer.configure(factory, connectionFactory);
31+
// You could still override some of Boot's default if necessary.
32+
return factory;
33+
}
34+
35+
@Bean // Serialize message content to json using TextMessage
36+
public MessageConverter jacksonJmsMessageConverter() {
37+
MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter();
38+
converter.setTargetType(MessageType.TEXT);
39+
converter.setTypeIdPropertyName("_type");
40+
return converter;
41+
}
42+
43+
public static void main(String[] args) {
44+
// Launch the application
45+
ConfigurableApplicationContext context = SpringApplication.run(JmsSampleApplication.class, args);
46+
47+
JmsTemplate jmsTemplate = context.getBean(JmsTemplate.class);
48+
49+
// Send a message with a POJO - the template reuse the message converter
50+
System.out.println("Sending an email message.");
51+
jmsTemplate.convertAndSend("mailbox", new Email("info@example.com", "Hello"));
52+
}
53+
54+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright (c) 2023, Oracle and/or its affiliates.
2+
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
3+
4+
package com.example.aqjms;
5+
6+
import org.springframework.jms.annotation.JmsListener;
7+
import org.springframework.stereotype.Component;
8+
9+
@Component
10+
public class Receiver {
11+
@JmsListener(destination = "mailbox", containerFactory = "myFactory")
12+
public void receiveMessage(Email email) {
13+
System.out.println("Received <" + email + ">");
14+
}
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
oracle.aq.username=pdbadmin
3+
oracle.aq.password=Welcome123
4+
oracle.aq.url=jdbc:oracle:thin:@//172.17.0.2:1521/pdb1
5+
oracle.aq.queue=mailbox

developer-preview/mbaas-developer-preview/sample-spring-apps/pom.xml

100755100644
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<module>bankb</module>
2121
<module>slow_service</module>
2222
<module>aqjms_sample</module>
23+
<module>aqjms-jakarta_sample</module>
2324
</modules>
2425

2526
<name>sample-spring-apps</name>
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
Oracle Free Use Terms and Conditions
2+
3+
Definitions
4+
5+
"Oracle" refers to Oracle America, Inc. "You" and "Your" refers to (a) a company or organization (each an "Entity")
6+
accessing the Programs, if use of the Programs will be on behalf of such Entity; or (b) an individual accessing the
7+
Programs, if use of the Programs will not be on behalf of an Entity. "Program(s)" refers to Oracle software provided
8+
by Oracle pursuant to the following terms and any updates, error corrections, and/or Program Documentation provided
9+
by Oracle. "Program Documentation" refers to Program user manuals and Program installation manuals, if any.
10+
If available, Program Documentation may be delivered with the Programs and/or may be accessed from
11+
www.oracle.com/documentation.
12+
"Separate Terms" refers to separate license terms that are specified in the Program Documentation, readmes or notice
13+
files and that apply to Separately Licensed Technology. "Separately Licensed Technology" refers to Oracle or third
14+
party technology that is licensed under Separate Terms and not under the terms of this license.
15+
16+
Separately Licensed Technology
17+
18+
Oracle may provide certain notices to You in Program Documentation, readmes or notice files in connection with Oracle
19+
or third party technology provided as or with the Programs. If specified in the Program Documentation, readmes or
20+
notice files, such technology will be licensed to You under Separate Terms. Your rights to use Separately Licensed
21+
Technology under Separate Terms are not restricted in any way by the terms herein. For clarity, notwithstanding
22+
the existence of a notice, third party technology that is not Separately Licensed Technology shall be deemed part
23+
of the Programs licensed to You under the terms of this license.
24+
25+
Source Code for Open Source Software
26+
27+
For software that You receive from Oracle in binary form that is licensed under an open source license that gives
28+
You the right to receive the source code for that binary, You can obtain a copy of the applicable source code from
29+
https://oss.oracle.com/sources/ or http://www.oracle.com/goto/opensourcecode. If the source code for such software
30+
was not provided to You with the binary, You can also receive a copy of the source code on physical media by
31+
submitting a written request pursuant to the instructions in the "Written Offer for Source Code" section of the
32+
latter website.
33+
34+
-------------------------------------------------------------------------------
35+
36+
The following license terms apply to those Programs that are not provided to You under Separate Terms.
37+
38+
License Rights and Restrictions
39+
40+
Oracle grants to You, as a recipient of this Program, a nonexclusive, nontransferable, limited license to, subject
41+
to the conditions stated herein, (a) internally use the unmodified Programs for the purposes of developing, testing,
42+
prototyping and demonstrating your applications, and running the Programs for your own internal business operations;
43+
and (b) redistribute unmodified Programs and Programs Documentation, under the terms of this License, provided that
44+
You do not charge Your end users any additional fees for the use of the Programs. You may make copies of the Programs
45+
to the extent reasonably necessary for exercising the license rights granted herein and for backup purposes. You are
46+
granted the right to use the Programs to provide third party training in the use of the Programs and associated
47+
Separately Licensed Technology only if there is express authorization of such use by Oracle on the Program's download
48+
page or in the Program Documentation.
49+
50+
Your license is contingent on Your compliance with the following conditions:
51+
52+
- You include a copy of this license with any distribution by You of the Programs;
53+
54+
- You do not remove markings or notices of either Oracle's or a licensor's proprietary rights from the Programs or
55+
Program Documentation;
56+
57+
- You comply with all U.S. and applicable export control and economic sanctions laws and regulations that govern
58+
Your use of the Programs (including technical data);
59+
60+
- You do not cause or permit reverse engineering, disassembly or decompilation of the Programs (except as allowed by law)
61+
by You nor allow an associated party to do so.
62+
63+
For clarity, any source code that may be included in the distribution with the Programs is provided solely for reference
64+
purposes and may not be modified, unless such source code is under Separate Terms permitting modification.
65+
66+
Ownership
67+
68+
Oracle or its licensors retain all ownership and intellectual property rights to the Programs.
69+
70+
Information Collection
71+
72+
The Programs' installation and/or auto-update processes, if any, may transmit a limited amount of data to Oracle
73+
or its service provider about those processes to help Oracle understand and optimize them. Oracle does not associate
74+
the data with personally identifiable information. Refer to Oracle's Privacy Policy at www.oracle.com/privacy.
75+
76+
Disclaimer of Warranties; Limitation of Liability
77+
78+
THE PROGRAMS ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. ORACLE FURTHER DISCLAIMS ALL WARRANTIES,
79+
EXPRESS AND IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR
80+
A PARTICULAR PURPOSE, OR NONINFRINGEMENT.
81+
82+
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL ORACLE BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL,
83+
SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING
84+
BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES
85+
OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN
86+
ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
87+
88+
Last updated: 9 October 2018

0 commit comments

Comments
 (0)