1
+ #! /bin/sh
2
+
3
+ #
4
+ # Copyright 2021 - 2022 the original author or authors.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # https://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+ scriptDir=$( dirname " ${BASH_SOURCE[0]} " )
19
+ resultDir=" $scriptDir /testcode/result"
20
+ resultAppDir=" $resultDir /spring-amqp-mule"
21
+ sbmRootDir=" $scriptDir /../.."
22
+
23
+
24
+ function pause(){
25
+ echo " =============================================================================================="
26
+ echo " -> $* "
27
+ echo " Press Enter to continue..."
28
+ read -p " =============================================================================================="
29
+ }
30
+
31
+ function stopApplication() {
32
+ PID=$( ps -ef | grep .jar | grep -v grep | awk ' { print $2 }' )
33
+ if [ -z " $PID " ]
34
+ then
35
+ echo Application is already stopped
36
+ else
37
+ echo kill $PID
38
+ kill $PID
39
+ fi
40
+ }
41
+
42
+ function cleanup() {
43
+ rm -rf $resultDir
44
+ mkdir $resultDir
45
+ }
46
+
47
+ echo " clean up..."
48
+ cleanup
49
+
50
+ echo " prepare demo..."
51
+ cp -R ./testcode/given/* $resultDir
52
+
53
+ echo " start infrastructure..."
54
+ docker-compose -f $resultDir /docker-compose.yaml stop && docker-compose -f $resultDir /docker-compose.yaml rm -f
55
+ docker-compose -f $resultDir /docker-compose.yaml rm -v
56
+ docker-compose -f $resultDir /docker-compose.yaml up -d --no-recreate
57
+
58
+ echo " init git..."
59
+ pushd $resultAppDir
60
+ git init .
61
+ git add .
62
+ git commit -am " initial commit"
63
+ popd
64
+
65
+ echo " build SBM..."
66
+ pushd $sbmRootDir
67
+ mvn clean package -DskipTests
68
+ popd
69
+
70
+ pause " start migration"
71
+
72
+ echo " start migration..."
73
+ java -jar $sbmRootDir /applications/spring-shell/target/spring-boot-migrator.jar @commands.txt
74
+
75
+ echo " build migrated application..."
76
+ pushd $resultAppDir
77
+ mvn clean package
78
+ mvn package spring-boot:repackage
79
+ idea .
80
+ popd
81
+
82
+ pause " start migrated application"
83
+
84
+ echo " start migrated spring boot application..."
85
+ nohup java -jar $resultAppDir /target/hellomule-migrated-1.0-SNAPSHOT.jar > ./application.log &
86
+
87
+ echo " Open RabbitMQ console and verify no messages exist: http://localhost:15672/#/queues/%2F/sales_queue"
88
+
89
+ pause " send message to REST endpoint"
90
+
91
+ # call migrated application
92
+ curl --location --request POST ' http://localhost:8081/' --header ' Content-Type: text/plain' --data-raw ' {"hello": "from mule spring world"}'
93
+
94
+ pause " Verify the messages was sent: http://localhost:15672/#/queues/%2F/sales_queue"
95
+
96
+ pause " shutdown"
97
+
98
+ echo " shutdown and cleanup..."
99
+
100
+ stopApplication
101
+
102
+ # shutdown infrastructure
103
+ docker-compose -f $resultDir /docker-compose.yaml stop && docker-compose -f $resultDir /docker-compose.yaml rm -f
104
+ docker-compose -f $resultDir /docker-compose.yaml rm -vs
105
+
106
+ cleanup
0 commit comments