Skip to content

Commit 70a7160

Browse files
committed
[JBTM-3571] LRA booking quickstart fails during recovery
using fixed name for coordinator runner Simplify LRA quickstart (remove LRA cancellation) Use the latest narayana version for the lra-coordinator-quarkus
1 parent 1f32612 commit 70a7160

File tree

11 files changed

+171
-106
lines changed

11 files changed

+171
-106
lines changed

rts/lra-examples/coordinator-quarkus/pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,12 @@
5353
<dependency>
5454
<groupId>org.jboss.narayana.rts</groupId>
5555
<artifactId>lra-coordinator-jar</artifactId>
56+
<version>${narayana.version}</version>
5657
</dependency>
5758
</dependencies>
5859

5960
<build>
61+
<finalName>lra-coordinator-quarkus</finalName>
6062
<plugins>
6163
<plugin>
6264
<groupId>io.quarkus</groupId>

rts/lra/README.adoc

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,19 @@ mvn clean package
88

99
start LRA 1
1010
Book hotel
11-
start LRA 2
12-
start LRA 3
11+
start nested LRA 2
1312
Book flight option 1
14-
start LRA 4
13+
start nested LRA 3
1514
Book flight option 2
16-
cancel LRA 3
17-
close LRA 1 (results in the hotel and flight option 2 being confirmed)
15+
cancel LRA 1 (results in the hotel and flights being cancelled)
1816

1917
### Before you start
2018

21-
Obtain and unzip the Narayana distribution containing the LRA coordinator to $NARAYANA_INSTALL_LOCATION
19+
Make sure you export the WORKSPACE variable to the absolute path to the quickstart folder, e.g. 'export WORKSPACE=/user/myuser/quickstart/'.
20+
21+
Make sure you have built the lra-coordinator-quarkus module, it is in $WORKSPACE/rts/lra-examples.
22+
23+
2224

2325
### Make sure the LRA coordinator and various services are running
2426

rts/lra/flight-service/pom.xml

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
</dependencyManagement>
2929

3030
<build>
31-
<finalName>lra-test</finalName>
3231
<plugins>
3332
<plugin>
3433
<artifactId>maven-surefire-plugin</artifactId>
@@ -79,12 +78,35 @@
7978
<artifactId>narayana-lra</artifactId>
8079
<version>${project.version}</version>
8180
</dependency>
82-
81+
<dependency>
82+
<groupId>org.jboss.narayana.rts</groupId>
83+
<artifactId>lra-client</artifactId>
84+
<version>${project.version}</version>
85+
</dependency>
86+
<dependency>
87+
<groupId>org.jboss.narayana.rts</groupId>
88+
<artifactId>lra-service-base</artifactId>
89+
<version>${project.version}</version>
90+
</dependency>
91+
<dependency>
92+
<groupId>org.jboss.narayana.rts</groupId>
93+
<artifactId>lra-proxy-api</artifactId>
94+
<version>${project.version}</version>
95+
</dependency>
8396
<!-- JAXRS 2 Client API implementation -->
8497
<dependency>
8598
<groupId>org.jboss.resteasy</groupId>
8699
<artifactId>resteasy-client</artifactId>
87-
<scope>test</scope>
100+
<scope>compile</scope>
101+
</dependency>
102+
<dependency>
103+
<groupId>commons-logging</groupId>
104+
<artifactId>commons-logging</artifactId>
105+
<version>1.2</version>
106+
</dependency>
107+
<dependency>
108+
<groupId>io.quarkus</groupId>
109+
<artifactId>quarkus-resteasy-jackson</artifactId>
88110
</dependency>
89111
<dependency>
90112
<groupId>com.fasterxml.jackson.core</groupId>

rts/lra/hotel-service/pom.xml

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
</dependencies>
2828
</dependencyManagement>
2929
<build>
30-
<finalName>lra-test</finalName>
3130
<plugins>
3231
<plugin>
3332
<artifactId>maven-surefire-plugin</artifactId>
@@ -72,19 +71,43 @@
7271
<artifactId>narayana-lra</artifactId>
7372
<version>${project.version}</version>
7473
</dependency>
74+
<dependency>
75+
<groupId>org.jboss.narayana.rts</groupId>
76+
<artifactId>lra-client</artifactId>
77+
<version>${project.version}</version>
78+
</dependency>
79+
<dependency>
80+
<groupId>org.jboss.narayana.rts</groupId>
81+
<artifactId>lra-service-base</artifactId>
82+
<version>${project.version}</version>
83+
</dependency>
84+
<dependency>
85+
<groupId>org.jboss.narayana.rts</groupId>
86+
<artifactId>lra-proxy-api</artifactId>
87+
<version>${project.version}</version>
88+
</dependency>
7589

7690
<!-- JAX-RS -->
7791
<dependency>
7892
<groupId>jakarta.ws.rs</groupId>
7993
<artifactId>jakarta.ws.rs-api</artifactId>
80-
<scope>provided</scope>
94+
<scope>compile</scope>
8195
</dependency>
8296

8397
<!-- JAXRS 2 Client API implementation -->
8498
<dependency>
8599
<groupId>org.jboss.resteasy</groupId>
86100
<artifactId>resteasy-client</artifactId>
87-
<scope>test</scope>
101+
<scope>compile</scope>
102+
</dependency>
103+
<dependency>
104+
<groupId>commons-logging</groupId>
105+
<artifactId>commons-logging</artifactId>
106+
<version>1.2</version>
107+
</dependency>
108+
<dependency>
109+
<groupId>io.quarkus</groupId>
110+
<artifactId>quarkus-resteasy-jackson</artifactId>
88111
</dependency>
89112
<dependency>
90113
<groupId>com.fasterxml.jackson.core</groupId>

rts/lra/run.sh

Lines changed: 44 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
#!/usr/bin/env bash
2+
3+
4+
if [[ ! -v WORKSPACE ]]; then
5+
echo "Please set the WORKSPACE variable to the root folder of the quickstart"
6+
exit -1
7+
fi
8+
9+
if [ ! -f $WORKSPACE/rts/lra-examples/coordinator-quarkus/target/lra-coordinator-quarkus-runner.jar ]; then
10+
echo "Please build first the lra-coordinator-quarkus module which is needed for this demo"
11+
exit -1
12+
fi
13+
214
function finish {
315
if ps -p $ID1 > /dev/null
416
then
@@ -24,10 +36,6 @@ function finish {
2436
then
2537
kill -9 $ID5
2638
fi
27-
28-
if [ -d "$NARAYANA_INSTALL_LOCATION" ]; then
29-
rm -rf $NARAYANA_INSTALL_LOCATION
30-
fi
3139
}
3240
trap finish EXIT
3341

@@ -59,32 +67,20 @@ function getDebugArgs {
5967

6068
cd "$( dirname "${BASH_SOURCE[0]}" )"
6169

62-
case "$(uname)" in
63-
CYGWIN*) export NARAYANA_INSTALL_LOCATION=`cygpath -w $(pwd)/narayana-full-7.0.3.Final-SNAPSHOT` ;;
64-
*) export NARAYANA_INSTALL_LOCATION=$(pwd)/narayana-full-7.0.3.Final-SNAPSHOT ;;
65-
esac
66-
67-
rm -rf $NARAYANA_INSTALL_LOCATION
68-
NARAYANA_ZIP="narayana-full-7.0.3.Final-SNAPSHOT-bin.zip"
69-
[ ! -f "$WORKSPACE/$NARAYANA_ZIP" ] &&\
70-
echo "There is no Narayana zip at \$WORKSPACE directory at '$WORKSPACE/$NARAYANA_ZIP" && exit 1
71-
unzip "$WORKSPACE/$NARAYANA_ZIP"
72-
7370
CURL_IP_OPTS=""
7471
IP_OPTS="${IPV6_OPTS}" # use setup of IPv6 if it's defined, otherwise go with IPv4
7572
if [ -z "$IP_OPTS" ]; then
7673
IP_OPTS="-Djava.net.preferIPv4Stack=true -Djava.net.preferIPv4Addresses"
7774
CURL_IP_OPTS="-4"
7875
fi
7976

80-
echo "Narayana installed location = $NARAYANA_INSTALL_LOCATION"
81-
java ${IP_OPTS} -Dquarkus.http.port=8080 $(getDebugArgs $PORT) -jar $NARAYANA_INSTALL_LOCATION/rts/lra/lra-coordinator-runner.jar &
77+
java ${IP_OPTS} -Dquarkus.http.port=8080 $(getDebugArgs $PORT) -jar $WORKSPACE/rts/lra-examples/coordinator-quarkus/target/lra-coordinator-quarkus-runner.jar &
8278
ID1=$!
8379
((PORT++))
84-
java ${IP_OPTS} -Dquarkus.http.port=8081 $(getDebugArgs $PORT) -jar $NARAYANA_INSTALL_LOCATION/rts/lra/lra-coordinator-runner.jar &
80+
java ${IP_OPTS} -Dquarkus.http.port=8081 $(getDebugArgs $PORT) -jar $WORKSPACE/rts/lra-examples/coordinator-quarkus/target/lra-coordinator-quarkus-runner.jar &
8581
ID2=$!
8682
((PORT++))
87-
java ${IP_OPTS} -Dquarkus.http.port=8082 $(getDebugArgs $PORT) -jar hotel-service/target/quarkus-app/quarkus-run.jar &
83+
java ${IP_OPTS} -Dquarkus.http.port=8082 -Dlra.http.port=8080 $(getDebugArgs $PORT) -jar hotel-service/target/quarkus-app/quarkus-run.jar &
8884
ID3=$!
8985
((PORT++))
9086
java ${IP_OPTS} -Dquarkus.http.port=8083 -Dlra.http.port=8081 $(getDebugArgs $PORT) -jar flight-service/target/quarkus-app/quarkus-run.jar &
@@ -97,24 +93,42 @@ echo "Narayana installed location = $NARAYANA_INSTALL_LOCATION"
9793
echo "Waiting for all the servers to start"
9894
sleep `timeout_adjust 30 2>/dev/null || echo 30`
9995

100-
mvn -f trip-client/pom.xml exec:java -Dexec.args="${IP_OPTS} confirm"
101-
mvn -f trip-client/pom.xml exec:java -Dexec.args="${IP_OPTS} cancel"
96+
MAVEN_OPTS=${IP_OPTS} mvn -f trip-client/pom.xml exec:java -Dexec.args="confirm"
97+
MAVEN_OPTS=${IP_OPTS} mvn -f trip-client/pom.xml exec:java -Dexec.args="cancel"
10298

10399
echo -e "\n\n\n"
104100
BOOKINGID=$(curl ${CURL_IP_OPTS} -X POST "http://localhost:8084/?hotelName=TheGrand&flightNumber1=BA123&flightNumber2=RH456" -sS | jq -r ".id")
105101
echo "Booking ID was: $BOOKINGID"
106102

103+
104+
###### START not working
105+
#When a coordinator killed and then restarted everything should keep working as usual
106+
#instead when restarting the coordinator the final status of the nested LRAs is not correct
107107
kill -9 $ID1
108-
java ${IP_OPTS} -Dquarkus.http.port=8080 $(getDebugArgs 8787) -jar $NARAYANA_INSTALL_LOCATION/rts/lra/lra-coordinator-runner.jar &
108+
java ${IP_OPTS} -Dquarkus.http.port=8080 $(getDebugArgs 8787) -jar $WORKSPACE/rts/lra-examples/coordinator-quarkus/target/lra-coordinator-quarkus-runner.jar &
109109
ID1=$!
110-
echo "Waiting for all the coordinator to recover"
111-
sleep `timeout_adjust 40 2>/dev/null || echo 40`
112-
echo -e "\n\n\n"
110+
########## END not working
111+
112+
echo "Waiting for all coordinators to recover"
113113

114+
sleep 40
115+
echo -e "\n\n\n"
114116
set +x
115-
echo "Confirming with curl ${CURL_IP_OPTS} -X PUT http://localhost:8084/`urlencode $BOOKINGID`"
116-
curl ${CURL_IP_OPTS} -X PUT http://localhost:8084/`urlencode $BOOKINGID`
117-
echo ""
118-
set -x
119117

120-
[ $DEBUG ] && echo "Processes are still running ($ID1 $ID2 $ID3 $ID4 $ID5) press any key to end them" && read
118+
echo "Cancelling with curl ${CURL_IP_OPTS} -X DELETE http://localhost:8084/`urlencode $BOOKINGID`"
119+
BOOKINIDENCODED=`urlencode $BOOKINGID`
120+
set -x
121+
echo $BOOKINIDENCODED
122+
RESPONSE=$(curl ${CURL_IP_OPTS} -X DELETE http://localhost:8084/$BOOKINIDENCODED -sS)
123+
echo -e "\nresponse is: \n $RESPONSE\n"
124+
125+
STATUS=$(echo $RESPONSE | jq -r ".status")
126+
if [ "$STATUS" != "CANCELLED" ]; then
127+
echo "The status is not 'CANCELLED': $STATUS"
128+
exit -1
129+
fi
130+
131+
if [ "$DEBUG" ]; then
132+
echo "Processes are still running ($ID1 $ID2 $ID3 $ID4 $ID5) press any key to end them"
133+
read
134+
fi

rts/lra/trip-client/pom.xml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<plugin>
2222
<groupId>org.codehaus.mojo</groupId>
2323
<artifactId>exec-maven-plugin</artifactId>
24-
<version>1.4.0</version>
24+
<version>3.1.0</version>
2525
<configuration>
2626
<mainClass>TripClient</mainClass>
2727
</configuration>
@@ -41,11 +41,27 @@
4141
<artifactId>narayana-lra</artifactId>
4242
<version>${project.version}</version>
4343
</dependency>
44+
<dependency>
45+
<groupId>org.jboss.narayana.rts</groupId>
46+
<artifactId>lra-client</artifactId>
47+
<version>${project.version}</version>
48+
</dependency>
49+
<dependency>
50+
<groupId>org.jboss.narayana.rts</groupId>
51+
<artifactId>lra-service-base</artifactId>
52+
<version>${project.version}</version>
53+
</dependency>
54+
<dependency>
55+
<groupId>org.jboss.narayana.rts</groupId>
56+
<artifactId>lra-proxy-api</artifactId>
57+
<version>${project.version}</version>
58+
</dependency>
4459

4560
<!-- JAXRS 2 Client API implementation -->
4661
<dependency>
4762
<groupId>org.jboss.resteasy</groupId>
4863
<artifactId>resteasy-client</artifactId>
64+
<scope>compile</scope>
4965
</dependency>
5066
<dependency>
5167
<groupId>com.fasterxml.jackson.core</groupId>

rts/lra/trip-controller/pom.xml

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
</dependencyManagement>
2929

3030
<build>
31-
<finalName>lra-test</finalName>
3231
<plugins>
3332
<plugin>
3433
<artifactId>maven-surefire-plugin</artifactId>
@@ -77,6 +76,21 @@
7776
<artifactId>narayana-lra</artifactId>
7877
<version>${project.version}</version>
7978
</dependency>
79+
<dependency>
80+
<groupId>org.jboss.narayana.rts</groupId>
81+
<artifactId>lra-client</artifactId>
82+
<version>${project.version}</version>
83+
</dependency>
84+
<dependency>
85+
<groupId>org.jboss.narayana.rts</groupId>
86+
<artifactId>lra-service-base</artifactId>
87+
<version>${project.version}</version>
88+
</dependency>
89+
<dependency>
90+
<groupId>org.jboss.narayana.rts</groupId>
91+
<artifactId>lra-proxy-api</artifactId>
92+
<version>${project.version}</version>
93+
</dependency>
8094

8195
<!-- JAX-RS -->
8296
<dependency>
@@ -89,8 +103,16 @@
89103
<dependency>
90104
<groupId>org.jboss.resteasy</groupId>
91105
<artifactId>resteasy-client</artifactId>
92-
<version>${version.resteasy}</version>
93-
<scope>test</scope>
106+
<scope>compile</scope>
107+
</dependency>
108+
<dependency>
109+
<groupId>commons-logging</groupId>
110+
<artifactId>commons-logging</artifactId>
111+
<version>1.2</version>
112+
</dependency>
113+
<dependency>
114+
<groupId>io.quarkus</groupId>
115+
<artifactId>quarkus-resteasy-jackson</artifactId>
94116
</dependency>
95117
<dependency>
96118
<groupId>com.fasterxml.jackson.core</groupId>

rts/lra/trip-controller/src/main/java/io/narayana/rts/lra/demo/tripcontroller/TripCheck.java

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import jakarta.ws.rs.core.Response;
77
import java.util.Arrays;
88

9+
import com.fasterxml.jackson.core.JsonProcessingException;
10+
911
/**
1012
* For testing - verify that the business data returned when ending an LRA is the same as that returned by directly
1113
* interrogating each sra.demo.service involved in the booking
@@ -37,14 +39,27 @@ static boolean validateBooking(Booking booking, boolean isConfirm, WebTarget hot
3739
});
3840

3941
if (isConfirm) {
40-
// the hotel and only one of the flight bookings should be confirmed
41-
if (confirmCount[0] != 2 || cancelCount[0] != 1) {
42-
System.out.printf("TripCheck: validateBooking: the hotel and only one of the flight bookings should have been confirmed%n");
42+
if (confirmCount[0] != 3) {
43+
try {
44+
System.out.println(
45+
"TripCheck: validateBooking: the hotel and 2 flight bookings should have been confirmed, but are "
46+
+ confirmCount[0] + "\n" + booking.toJson());
47+
}
48+
catch (JsonProcessingException e) {
49+
e.printStackTrace();
50+
}
4351
return false;
4452
}
4553
} else {
4654
if (cancelCount[0] != 3) {
47-
System.out.printf("TripCheck: validateBooking: the hotel and both flight bookings should have be cancelled%n");
55+
try {
56+
System.out.println(
57+
"TripCheck: validateBooking: the hotel and both flight bookings should have been cancelled, but are "
58+
+ cancelCount[0] + "\n" + booking.toJson());
59+
}
60+
catch (JsonProcessingException e) {
61+
e.printStackTrace();
62+
}
4863
return false;
4964
}
5065
}

0 commit comments

Comments
 (0)