Skip to content

Commit 180dddb

Browse files
authored
Queue reader (#884)
tolldemo work
1 parent c2c5ee5 commit 180dddb

File tree

44 files changed

+617
-63
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+617
-63
lines changed

tolldemo/data-generator/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>org.springframework.boot</groupId>
77
<artifactId>spring-boot-starter-parent</artifactId>
8-
<version>3.2.4</version>
8+
<version>3.2.5</version>
99
<relativePath/> <!-- lookup parent from repository -->
1010
</parent>
1111
<groupId>com.example</groupId>

tolldemo/data-generator/src/main/java/com/example/datagenerator/DataGeneratorApplication.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Copyright (c) 2024, 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+
14
package com.example.datagenerator;
25

36
import java.io.BufferedReader;
@@ -6,7 +9,7 @@
69
import java.io.FileWriter;
710
import java.io.IOException;
811
import java.util.ArrayList;
9-
import java.util.List;
12+
// import java.util.List;
1013
import java.util.Random;
1114
import java.util.UUID;
1215

tolldemo/data-generator/src/main/java/com/example/datagenerator/State.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Copyright (c) 2024, 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+
14
package com.example.datagenerator;
25

36
import java.util.Random;

tolldemo/data-generator/src/main/resources/application.properties

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
spring:
2+
application:
3+
name: data-generator

tolldemo/data-generator/src/main/resources/nj-zipcodes-placenames.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
08210 Cape May Court House
117117
08212 Cape May Point
118118
07072 Carlstadt
119-
08069 Carney's Point
119+
08069 Carneys Point
120120
07008 Carteret
121121
08018 Cedar Brook
122122
07009 Cedar Grove
@@ -828,7 +828,7 @@
828828
07512 Totowa
829829
07082 Towaco
830830
07052 Town Center
831-
08243 Townsend's Inlet
831+
08243 Townsends Inlet
832832
07879 Tranquility
833833
08600 Trenton
834834
08601 Trenton

tolldemo/data-generator/src/main/resources/street-names.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Moorgate Street
3333
Hollytree Gardens
3434
Goldings Road
3535
Highmoor Close
36-
St James's Road
36+
St James Road
3737
Yardley Close
3838
St Leonards Avenue
3939
Althorp Road

tolldemo/data-generator/src/test/java/com/example/datagenerator/DataGeneratorApplicationTests.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Copyright (c) 2024, 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+
14
package com.example.datagenerator;
25

36
import org.junit.jupiter.api.Test;

tolldemo/journal-app/src/main/java/com/example/journalapp/JournalAppApplication.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Copyright (c) 2024, 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+
14
package com.example.journalapp;
25

36
import org.springframework.boot.SpringApplication;
@@ -9,5 +12,4 @@ public class JournalAppApplication {
912
public static void main(String[] args) {
1013
SpringApplication.run(JournalAppApplication.class, args);
1114
}
12-
1315
}

tolldemo/journal-app/src/main/java/com/example/journalapp/controller/JournalController.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
// Copyright (c) 2024, 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+
14
package com.example.journalapp.controller;
25

36
import com.example.journalapp.model.Journal;
4-
//import com.example.journalapp.model.JournalJDBC;
57
import com.example.journalapp.repository.JournalRepository;
6-
//import com.example.journalapp.service.JournalService;
78
import lombok.extern.slf4j.Slf4j;
89
import org.springframework.http.HttpStatus;
910
import org.springframework.http.ResponseEntity;
@@ -26,7 +27,7 @@ public JournalController(JournalRepository journalRepository) {
2627
this.journalRepository = journalRepository;
2728
}
2829

29-
// http POST :8080/api/v1/journal tagId=tagid licensePlate=licplate vehicleType=vtype tollDate=tdate
30+
// http POST :8080/api/v1/journal tagId=tagid accountNumber=acctnum licensePlate=licplate vehicleType=vtype tollDate=tdate tollCost=1
3031
@PostMapping("/journal")
3132
public ResponseEntity<Journal> createAccount(@RequestBody Journal journal) {
3233
log.info("Creating journal {}", journal);

tolldemo/journal-app/src/main/java/com/example/journalapp/model/Journal.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Copyright (c) 2024, 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+
14
package com.example.journalapp.model;
25

36
import jakarta.persistence.Column;
@@ -21,6 +24,8 @@ public class Journal {
2124
@Column(name = "JOURNAL_ID")
2225
@GeneratedValue(strategy = GenerationType.IDENTITY)
2326
private Integer journalId;
27+
@Column(name = "ACCOUNT_NUMBER")
28+
private String accountNumber;
2429
@Column(name = "TAG_ID")
2530
private String tagId;
2631
@Column(name = "LICENSE_PLATE")
@@ -29,6 +34,7 @@ public class Journal {
2934
private String vehicleType;
3035
@Column(name = "TOLL_DATE")
3136
private String tollDate;
37+
@Column(name = "TOLL_COST")
38+
private Integer tollCost;
3239

3340
}
34-

tolldemo/journal-app/src/main/java/com/example/journalapp/repository/JournalRepository.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
// Copyright (c) 2024, 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+
14
package com.example.journalapp.repository;
25

36
import com.example.journalapp.model.Journal;
4-
//import com.example.journalapp.model.JournalJDBC;
57
import org.springframework.data.jpa.repository.JpaRepository;
68

79
public interface JournalRepository extends JpaRepository<Journal, Long> {
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# mvn clean spring-boot:run -Dspring-boot.run.profiles=local
2+
spring:
3+
application:
4+
name: journal-app
5+
threads:
6+
virtual:
7+
enabled: true
8+
jpa:
9+
hibernate:
10+
ddl-auto: validate
11+
12+
datasource:
13+
url: jdbc:oracle:thin:@//localhost:1521/orclpdb1
14+
username: tolldemo
15+
password: Welcome12345
16+
driver-class-name: oracle.jdbc.OracleDriver
17+
type: oracle.ucp.jdbc.PoolDataSource
18+
oracleucp:
19+
connection-factory-class-name: oracle.jdbc.pool.OracleDataSource
20+
connection-pool-name: JournalAppConnectionPool
21+
initial-pool-size: 15
22+
min-pool-size: 10
23+
max-pool-size: 30

tolldemo/journal-app/src/main/resources/application.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ spring:
99
ddl-auto: validate
1010

1111
datasource:
12-
url: jdbc:oracle:thin:@//localhost:1521/orclpdb1
13-
username: tolldemo
14-
password: Welcome12345
12+
url: ${spring.datasource.url}
13+
username: ${spring.datasource.username}
14+
password: ${spring.datasource.password}
1515
driver-class-name: oracle.jdbc.OracleDriver
1616
type: oracle.ucp.jdbc.PoolDataSource
1717
oracleucp:
1818
connection-factory-class-name: oracle.jdbc.pool.OracleDataSource
1919
connection-pool-name: JournalAppConnectionPool
2020
initial-pool-size: 15
2121
min-pool-size: 10
22-
max-pool-size: 30
22+
max-pool-size: 30
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
drop table if exists journal cascade constraints;
22

33
create table if not exists journal (
4-
JOURNAL_ID NUMBER GENERATED ALWAYS AS IDENTITY (START WITH 1 CACHE 20),
4+
JOURNAL_ID NUMBER GENERATED ALWAYS AS IDENTITY (START WITH 1 CACHE 20) primary key not null,
5+
account_number varchar2(10),
56
tag_id varchar2(64),
67
license_plate varchar2(10),
78
vehicle_type varchar2(10),
8-
toll_date varchar2(25)
9+
toll_date varchar2(25),
10+
toll_cost number
911
);
10-
11-
ALTER TABLE journal ADD CONSTRAINT jounral_PK PRIMARY KEY (journal_id) USING INDEX LOGGING;

tolldemo/journal-app/src/test/java/com/example/journalapp/JournalAppApplicationTests.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Copyright (c) 2024, 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+
14
package com.example.journalapp;
25

36
import org.junit.jupiter.api.Test;

tolldemo/label-generator/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>org.springframework.boot</groupId>
77
<artifactId>spring-boot-starter-parent</artifactId>
8-
<version>3.2.4</version>
8+
<version>3.2.5</version>
99
<relativePath/> <!-- lookup parent from repository -->
1010
</parent>
1111
<groupId>com.example</groupId>

tolldemo/label-generator/src/main/java/com/example/labelgenerator/LabelGeneratorApplication.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Copyright (c) 2024, 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+
14
package com.example.labelgenerator;
25

36
import java.io.BufferedReader;

tolldemo/label-generator/src/test/java/com/example/labelgenerator/LabelGeneratorApplicationTests.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Copyright (c) 2024, 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+
14
package com.example.labelgenerator;
25

36
import org.junit.jupiter.api.Test;

tolldemo/queue-reader/.gitignore

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
HELP.md
2+
target/
3+
!.mvn/wrapper/maven-wrapper.jar
4+
!**/src/main/**/target/
5+
!**/src/test/**/target/
6+
7+
### STS ###
8+
.apt_generated
9+
.classpath
10+
.factorypath
11+
.project
12+
.settings
13+
.springBeans
14+
.sts4-cache
15+
16+
### IntelliJ IDEA ###
17+
.idea
18+
*.iws
19+
*.iml
20+
*.ipr
21+
22+
### NetBeans ###
23+
/nbproject/private/
24+
/nbbuild/
25+
/dist/
26+
/nbdist/
27+
/.nb-gradle/
28+
build/
29+
!**/src/main/**/build/
30+
!**/src/test/**/build/
31+
32+
### VS Code ###
33+
.vscode/

tolldemo/queue-reader/pom.xml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<parent>
6+
<groupId>org.springframework.boot</groupId>
7+
<artifactId>spring-boot-starter-parent</artifactId>
8+
<version>3.2.5</version>
9+
<relativePath/> <!-- lookup parent from repository -->
10+
</parent>
11+
<groupId>com.example</groupId>
12+
<artifactId>queue-reader</artifactId>
13+
<version>0.0.1-SNAPSHOT</version>
14+
<name>queue-reader</name>
15+
<description>queue-reader</description>
16+
<properties>
17+
<java.version>21</java.version>
18+
<spring-cloud.version>2023.0.1</spring-cloud.version>
19+
<oracle-springboot-starter.version>23.4.0</oracle-springboot-starter.version>
20+
</properties>
21+
<dependencies>
22+
<dependency>
23+
<groupId>org.springframework.boot</groupId>
24+
<artifactId>spring-boot-starter-actuator</artifactId>
25+
</dependency>
26+
<dependency>
27+
<groupId>org.springframework.cloud</groupId>
28+
<artifactId>spring-cloud-starter-openfeign</artifactId>
29+
</dependency>
30+
<dependency>
31+
<groupId>com.oracle.database.spring</groupId>
32+
<artifactId>oracle-spring-boot-starter-aqjms</artifactId>
33+
<version>${oracle-springboot-starter.version}</version>
34+
</dependency>
35+
<dependency>
36+
<groupId>com.fasterxml.jackson.core</groupId>
37+
<artifactId>jackson-core</artifactId>
38+
<version>2.17.0</version>
39+
</dependency>
40+
<dependency>
41+
<groupId>org.springframework.boot</groupId>
42+
<artifactId>spring-boot-starter-test</artifactId>
43+
<scope>test</scope>
44+
</dependency>
45+
</dependencies>
46+
<dependencyManagement>
47+
<dependencies>
48+
<dependency>
49+
<groupId>org.springframework.cloud</groupId>
50+
<artifactId>spring-cloud-dependencies</artifactId>
51+
<version>${spring-cloud.version}</version>
52+
<type>pom</type>
53+
<scope>import</scope>
54+
</dependency>
55+
</dependencies>
56+
</dependencyManagement>
57+
58+
<build>
59+
<plugins>
60+
<plugin>
61+
<groupId>org.springframework.boot</groupId>
62+
<artifactId>spring-boot-maven-plugin</artifactId>
63+
</plugin>
64+
</plugins>
65+
</build>
66+
67+
</project>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright (c) 2024, 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.queuereader;
5+
6+
import org.springframework.boot.SpringApplication;
7+
import org.springframework.boot.autoconfigure.SpringBootApplication;
8+
import org.springframework.cloud.openfeign.EnableFeignClients;
9+
import org.springframework.jms.annotation.EnableJms;
10+
11+
@EnableJms
12+
@SpringBootApplication
13+
@EnableFeignClients
14+
public class QueueReaderApplication {
15+
16+
public static void main(String[] args) {
17+
SpringApplication.run(QueueReaderApplication.class, args);
18+
}
19+
20+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright (c) 2024, 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.queuereader.client;
5+
6+
import com.fasterxml.jackson.databind.JsonNode;
7+
import org.springframework.cloud.openfeign.FeignClient;
8+
import org.springframework.web.bind.annotation.PostMapping;
9+
import org.springframework.web.bind.annotation.RequestBody;
10+
11+
@FeignClient(name = "journal", url = "http://localhost:8080")
12+
public interface JournalClient {
13+
14+
@PostMapping("/api/v1/journal")
15+
void journal(@RequestBody JsonNode tollData);
16+
}

0 commit comments

Comments
 (0)