Skip to content

Commit f817037

Browse files
johneytsaigvenzl
andauthored
Sample Saga Application (#293)
* Initial Import * Update README * Add gitignore to Exclude * Update README * Update package.json * Update README * Update README --------- Co-authored-by: Gerald Venzl <gerald.venzl@oracle.com>
1 parent f5b3148 commit f817037

Some content is hidden

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

48 files changed

+4995
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
classes/
55
built/
66
.*
7+
!.gitignore

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ This repository stores a variety of examples demonstrating how to use the Oracle
1515
| [plsql](./plsql) | PL/SQL examples |
1616
| [python](./python) | Python examples |
1717
| [ruby](./ruby) | Ruby examples |
18+
| [sagas](./sagas) | Saga examples |
1819
| [security](./security) | Security features examples |
1920
| [spatial](./spatial) | Spatial features examples |
2021
| [sql](./sql) | SQL examples |

sagas/.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
node_modules
2+
report.html
3+
test.json
4+
target/
5+
.DS_Store
6+
*.log
7+
*.jar
8+
.settings
9+
initdb.sh
10+
/.metadata/
11+
app.properties
12+
application.properties
13+
osaga.app.properties
14+
*.swp
15+
*.sql

sagas/README.md

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# SagaBenchmark
2+
3+
Repository for saga benchmark application. This application mimics a real application and drives a saga workload for various participants.
4+
5+
## Getting started
6+
7+
In order to drive the application, you will need to install Artillery (global installation is recommended).
8+
9+
```
10+
npm install -g artillery@latest
11+
```
12+
13+
Then install all of the driver dependencies via npm
14+
15+
```
16+
npm install
17+
```
18+
19+
Set up the connection properties
20+
21+
Copy the template file `application.properties.example` in src/main/resources in the parent module to `application.properties`. Modify the property file to fit your environment. This only needs to be done once. A wallet and tnsnames.ora is required, see https://docs.oracle.com/middleware/1213/wls/JDBCA/oraclewallet.htm#JDBCA598 on how to create a wallet.
22+
23+
Run `mvn clean install` which will copy the properties file as well as build and package each of the applications.
24+
25+
From the root directory, create a `sql` directory, i.e., `mkdir sql` then run `mvn exec:java -pl sqlgenerator`. This will run the sql generator program that will generate all of the necessary sql scripts into the `sql` subdirectory. Modify `setupPDBS.sql` to match your CDB details, specifically, change `<seed_database>` on the `create pluggable database` lines to the value of your seed database.
26+
27+
Copy `initdb.sh.example` to `initdb.sh` and mark it as executable, i.e. `chmod a+x ./initdb.sh`
28+
29+
Modify `initdb.sh` with the correct credentials and connection strings for the environment. To (re)initialize the database, run `./initdb.sh`
30+
31+
**Note**: `sqlplus` is required and must be in your path.
32+
33+
## Usage
34+
35+
From the base directory, run `mvn clean install` to build everything.
36+
37+
**Optional** Copy setenv.sh into the bin folder of the Tomcat directory. This will add some network and JMS tuning as well as add some additional logging.
38+
39+
The application is split into 4 components. The Travel Agency is a WAR that needs to be deployed into a Tomcat 10 container. The Airline and Car applications are standalone Java apps. To start the Airline, run `mvn exec:java` from the airline directory. Similary, to start Car, run `mvn exec:java` from the car directory.
40+
41+
To run the driver, run `npm start` (you may need to run `npm install` first to install the JavaScript dependencies).
42+
43+
This will produce a `report.html` in the same directory which shows the results of the run.
44+
45+
## Benchmark Parameters
46+
47+
### application.properties
48+
49+
* maxStatusWait
50+
51+
The status endpoint will check to see when the original request was sent to create the saga. On each invocation of the status endpoint, it will check the delta between the creation time and now. If that exceeds `maxStatusWait`, the endpoint will return a 504. This parameter is in milliseconds.
52+
53+
* cacheSize
54+
55+
The initial cache size for each of the participants. This cache is used to maintain saga state information during the run such as compensation information.
56+
57+
* queuePartitions
58+
59+
The number of queues to use at each of participants (plus internal infrastructure).
60+
61+
* numOfFlightsToCreate
62+
63+
This property indicates how many flights should be added to the Flights table. This information will be used to create a payload for booking an airline.
64+
65+
### driver.yaml
66+
67+
* statusWait
68+
69+
How long the driver will wait (in seconds) between status checks to see if the saga has completed.
70+
71+
## Misc
72+
73+
### Sample Payload
74+
```
75+
{
76+
"flight": {
77+
"action": "Booking",
78+
"passengers": [
79+
{
80+
"firstName": "Jack",
81+
"lastName": "Frost",
82+
"birthdate": "1992-02-10",
83+
"gender": "F",
84+
"email": "sbt@yahoo.com",
85+
"phonePrimary": "949-767-9979",
86+
"flightId": "1",
87+
"seatType": "ECONOMY_SEATS",
88+
"seatNumber": "23A"
89+
},
90+
{
91+
"firstName": "Sam",
92+
"lastName": "Frost",
93+
"birthdate": "1990-08-30",
94+
"gender": "M",
95+
"email": "snua@yahoo.com",
96+
"phonePrimary": "949-767-9967",
97+
"flightId": "1",
98+
"seatType": "ECONOMY_SEATS",
99+
"seatNumber": "23B"
100+
}
101+
]
102+
},
103+
"car": {
104+
"action": "Booking",
105+
"customer": "John Case",
106+
"phone": "898-908-9080",
107+
"driversLicense": "B189391",
108+
"birthdate": "1976-03-04",
109+
"startDate": "2022-04-05",
110+
"endDate": "2022-04-15",
111+
"carType": "Van"
112+
}
113+
}
114+
```

sagas/airline/pom.xml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
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>com.oracle.database.sagabenchmark</groupId>
7+
<artifactId>sagabenchmark</artifactId>
8+
<version>1.0-SNAPSHOT</version>
9+
</parent>
10+
11+
<artifactId>airline</artifactId>
12+
13+
<properties>
14+
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
15+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
16+
</properties>
17+
18+
<build>
19+
<plugins>
20+
<plugin>
21+
<groupId>org.codehaus.mojo</groupId>
22+
<artifactId>exec-maven-plugin</artifactId>
23+
<version>3.1.0</version>
24+
<configuration>
25+
<mainClass>com.oracle.saga.airline.Airline</mainClass>
26+
<cleanupDaemonThreads>false</cleanupDaemonThreads>
27+
<systemProperties>
28+
<property>
29+
<key>oracle.jms.useJmsNotification</key>
30+
<value>false</value>
31+
</property>
32+
<property>
33+
<key>oracle.jms.maxSleepTime</key>
34+
<value>1</value>
35+
</property>
36+
<property>
37+
<key>oracle.jms.setNetworkTimeout</key>
38+
<value>false</value>
39+
</property>
40+
<property>
41+
<key>oracle.jms.traceLevel</key>
42+
<value>1</value>
43+
</property>
44+
<property>
45+
<key>oracle.jms.traceFile</key>
46+
<value>./logs/jms.log</value>
47+
</property>
48+
</systemProperties>
49+
</configuration>
50+
</plugin>
51+
<plugin>
52+
<artifactId>maven-resources-plugin</artifactId>
53+
<version>3.1.0</version>
54+
<executions>
55+
<execution>
56+
<id>copy-resources</id>
57+
<phase>process-resources</phase>
58+
<goals>
59+
<goal>copy-resources</goal>
60+
</goals>
61+
<configuration>
62+
<outputDirectory>${basedir}/src/main/resources</outputDirectory>
63+
<resources>
64+
<resource>
65+
<directory>${project.parent.basedir}/src/main/resources</directory>
66+
<includes>
67+
<include>**/*application.properties</include>
68+
</includes>
69+
<filtering>true</filtering>
70+
</resource>
71+
</resources>
72+
</configuration>
73+
</execution>
74+
</executions>
75+
</plugin>
76+
</plugins>
77+
78+
</build>
79+
80+
<dependencies>
81+
<dependency>
82+
<groupId>com.oracle.database.sagabenchmark</groupId>
83+
<artifactId>travelagency</artifactId>
84+
<version>[.1,)</version>
85+
<classifier>client</classifier>
86+
</dependency>
87+
</dependencies>
88+
</project>

0 commit comments

Comments
 (0)