forked from aliyun/ros-templates
-
Notifications
You must be signed in to change notification settings - Fork 1
/
through-RocketMQ-transaction-messages.yml
415 lines (413 loc) · 13.7 KB
/
through-RocketMQ-transaction-messages.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
ROSTemplateFormatVersion: '2015-09-01'
Description:
en: Distributed transactions are implemented through RocketMQ transaction messages.
zh-cn: 通过RocketMQ事务消息实现分布式事务。
Parameters:
ZoneId:
Type: String
AssociationProperty: ALIYUN::ECS::Instance::ZoneId
AssociationPropertyMetadata:
AutoSelectFirst: true
Label:
en: Availability Zone
zh-cn: 可用区
InstanceType:
Type: String
AssociationProperty: ALIYUN::ECS::Instance::InstanceType
AssociationPropertyMetadata:
InstanceChargeType: PostPaid
SystemDiskCategory: cloud_essd
ZoneId: ${ZoneId}
Label:
en: Instance Type
zh-cn: 实例规格
InstancePassword:
NoEcho: true
Type: String
Description:
en: Server login password, Length 8-30, must contain three(Capital letters, lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in)
zh-cn: 服务器登录密码,长度8-30,必须包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符号)
Label:
en: ECS Instance Password
zh-cn: ECS实例密码
ConstraintDescription:
en: Length 8-30, must contain three(Capital letters, lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in)
zh-cn: 长度8-30,必须包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符号)
AssociationProperty: ALIYUN::ECS::Instance::Password
CommonName:
Type: String
Default: rocketmq-transcation
DBInstanceClass:
Type: String
Label:
en: Instance Class
zh-cn: 实例类型
Description:
en: Database instance type. Refer the RDS database instance type.<a href='https://www.alibabacloud.com/help/doc-detail/26312.htm' target='_blank'>View RDS resources type</a>
zh-cn: '数据库实例类型, <br>详见: <a href=''https://help.aliyun.com/document_detail/26312.html'' target=''_blank''><b><font color=''blue''>实例规格表</font></b></a>.'
AssociationProperty: ALIYUN::RDS::Instance::InstanceType
AssociationPropertyMetadata:
Engine: MySQL
Category: Basic
EngineVersion: '8.0'
ZoneId: ${ZoneId}
CommodityCode: bards
DBInstanceStorageType: cloud_essd
Default: mysql.n2e.small.1
AccountName:
Type: String
Label:
en: Database Account
zh-cn: 数据库账号
Description:
en: The account name must be 2 to 32 characters in length and can contain lowercase letters, digits, and underscores (_). It must start with a letter and end with a letter or digit.
zh-cn: 由小写字母、数字、下划线(_)组成,以字母开头,以字母或数字结尾,最多32个字符。
AllowedPattern: ^(?!root$)[a-z][a-z0-9_]{0,30}[a-z0-9]$
Default: user_test
DBPassword:
NoEcho: true
Type: String
Description:
en: 'The password is 8 to 30 characters in length and must contain at least three types: uppercase letters, lowercase letters, digits, and special symbols. The name contains 8 to 32 characters. Special characters include! @ # $% ^ & * () _ + - ='
zh-cn: '数据库账号密码,长度8-30,必须包含三种及以上类型:大写字母、小写字母、数字、特殊符号。长度为8~32位。特殊字符包括! @ # $ % ^ & * () _ + - ='
Label:
en: MySQL Instance Password
zh-cn: MySQL数据库密码
ConstraintDescription:
en: 'Length 8-30, must contain three(Capital letters, lowercase letters, numbers, @ # $% ^ & * () _ + - = Special symbol in)'
zh-cn: '长度8-30,必须包含三项(大写字母、小写字母、数字、特殊符号。长度为8~32位。特殊字符包括! @ # $ % ^ & * () _ + - =)'
AssociationProperty: ALIYUN::RDS::Instance::AccountPassword
AppDemoAccountName:
Type: String
Label:
en: App demo username
zh-cn: 登录演示账户的用户名
Description:
en: The account name must be 2 to 32 characters in length and can contain lowercase letters, digits, and underscores (_). It must start with a letter and end with a letter or digit.
zh-cn: 由小写字母、数字、下划线(_)组成,以字母开头,以字母或数字结尾,最多32个字符。
AllowedPattern: ^(?!root$)[a-z][a-z0-9_]{0,30}[a-z0-9]$
Default: app_demo_user
AppDemoPassword:
NoEcho: true
Type: String
Label:
en: App demo password
zh-cn: 登录演示账户的密码
Description:
en: 'The password is 8 to 30 characters in length and must contain at least three types: uppercase letters, lowercase letters, digits, and special symbols. The name contains 8 to 32 characters. Special characters include! @ # $% ^ & * () _ + - ='
zh-cn: '账号密码,长度8-30,必须包含三种及以上类型:大写字母、小写字母、数字、特殊符号。长度为8~32位。特殊字符包括! @ # $ % ^ & * () _ + - ='
ConstraintDescription:
en: 'Length 8-30, must contain three(Capital letters, lowercase letters, numbers, @ # $% ^ & * () _ + - = Special symbol in)'
zh-cn: '长度8-30,必须包含三项(大写字母、小写字母、数字、特殊符号。长度为8~32位。特殊字符包括! @ # $ % ^ & * () _ + - =)'
AssociationProperty: ALIYUN::RDS::Instance::AccountPassword
Resources:
Vpc:
Type: ALIYUN::ECS::VPC
Properties:
CidrBlock: 192.168.0.0/16
VpcName:
Fn::Sub: vpc_${CommonName}
VSwitch1:
Type: ALIYUN::ECS::VSwitch
Properties:
VpcId:
Ref: Vpc
CidrBlock: 192.168.0.0/24
ZoneId:
Ref: ZoneId
VSwitchName:
Fn::Sub: vsw_app_01_${CommonName}
VSwitch2:
Type: ALIYUN::ECS::VSwitch
Properties:
VpcId:
Ref: Vpc
CidrBlock: 192.168.1.0/24
ZoneId:
Ref: ZoneId
VSwitchName:
Fn::Sub: vsw_app_02_${CommonName}
VSwitch3:
Type: ALIYUN::ECS::VSwitch
Properties:
VpcId:
Ref: Vpc
CidrBlock: 192.168.2.0/24
ZoneId:
Ref: ZoneId
VSwitchName:
Fn::Sub: vsw_db_${CommonName}
VSwitch4:
Type: ALIYUN::ECS::VSwitch
Properties:
VpcId:
Ref: Vpc
CidrBlock: 192.168.3.0/24
ZoneId:
Ref: ZoneId
VSwitchName:
Fn::Sub: vsw_mq_${CommonName}
SecurityGroup:
Type: ALIYUN::ECS::SecurityGroup
Properties:
VpcId:
Ref: Vpc
SecurityGroupName:
Fn::Sub: sg-${CommonName}
SecurityGroupIngress:
- PortRange: 80/80
SourceCidrIp: 0.0.0.0/0
IpProtocol: tcp
- PortRange: 22/22
SourceCidrIp: 47.96.60.0/24,118.31.243.0/24,8.139.112.0/24,8.139.99.192/26
IpProtocol: tcp
EcsInstance:
Type: ALIYUN::ECS::InstanceGroup
Count: 2
Properties:
VpcId:
Ref: Vpc
ZoneId:
Ref: ZoneId
VSwitchId:
Fn::Select:
- Ref: ALIYUN::Index
- - Ref: VSwitch1
- Ref: VSwitch2
SecurityGroupId:
Ref: SecurityGroup
ImageId: aliyun_3_x64_20G_alibase_
InstanceName:
Fn::Sub: ${CommonName}-ecs-${ALIYUN::Index}
InstanceType:
Ref: InstanceType
SystemDiskCategory: cloud_essd
SystemDiskSize: 40
MaxAmount: 1
InternetMaxBandwidthOut: 5
Password:
Ref: InstancePassword
Database:
Type: ALIYUN::RDS::DBInstance
Properties:
VpcId:
Ref: Vpc
VSwitchId:
Ref: VSwitch3
DBInstanceClass:
Ref: DBInstanceClass
DBInstanceNetType: Intranet
SecurityGroupId:
Ref: SecurityGroup
DBInstanceStorage: 40
Category: Basic
MultiAZ: false
DBInstanceStorageType: cloud_essd
Engine: MySQL
EngineVersion: '8.0'
DBMappings:
- CharacterSetName: utf8mb4
DBName: rocketmq_transaction_db
SecurityIPList: 192.168.0.0/16
Account:
Type: ALIYUN::RDS::Account
Properties:
AccountName:
Ref: AccountName
AccountType: Super
AccountPassword:
Ref: DBPassword
DBInstanceId:
Ref: Database
RocketMQ:
Type: ALIYUN::ROCKETMQ5::Instance
Properties:
ProductInfo:
MsgProcessSpec: rmq.s2.2xlarge
InternetInfo:
InternetSpec: disable
SubSeriesCode: cluster_ha
InstanceName:
Fn::Sub: ${CommonName}-mq
SeriesCode: standard
PaymentType: PayAsYouGo
VpcInfo:
VpcId:
Ref: Vpc
VSwitchId:
Ref: VSwitch4
Topic:
Type: ALIYUN::ROCKETMQ5::Topic
Properties:
InstanceId:
Ref: RocketMQ
MessageType: TRANSACTION
Remark: 用于存储和传输订单相关的业务消息
TopicName:
Fn::Sub: ROCKETMQ_ORDER_TOPIC
ConsumerGroup:
Type: ALIYUN::ROCKETMQ5::ConsumerGroup
DependsOn:
- Topic
Properties:
ConsumerGroupId:
Fn::Sub: ROCKETMQ_LOGISTIC_CONSUMER_GROUP
InstanceId:
Ref: RocketMQ
ConsumeRetryPolicy:
RetryPolicy: DefaultRetryPolicy
MaxRetryTimes: 5
DeliveryOrderType: Concurrently
AutoEnableCDT:
Type: ALIYUN::ROS::AutoEnableService
Properties:
ServiceName: CDT
WaitConditionHandle:
Type: ALIYUN::ROS::WaitConditionHandle
Properties: { }
RosWaitCondition:
Type: ALIYUN::ROS::WaitCondition
Properties:
Count: 2
Handle:
Ref: WaitConditionHandle
Timeout: 7200
ProductRunCommand:
Type: ALIYUN::ECS::RunCommand
DependsOn:
- ConsumerGroup
Properties:
InstanceIds:
Fn::Select:
- 1
- Fn::GetAtt:
- EcsInstance
- InstanceIds
Type: RunShellScript
Sync: true
Timeout: 7200
CommandContent:
Fn::Sub: |-
#!/bin/bash
cat << EOF >> ~/.bash_profile
export MYSQL_HOST=${Database.InnerConnectionString}
export MYSQL_DB=rocketmq_transaction_db
export MYSQL_USER=${AccountName}
export MYSQL_PASSWORD=${DBPassword}
export APP_DEMO_ROCKETMQ_ENDPOINT=${RocketMQ.VpcEndpoint}
export APP_DEMO_ROCKETMQ_USERNAME=${RocketMQ.UserName}
export APP_DEMO_ROCKETMQ_PASSWORD=${RocketMQ.Password}
export APP_DEMO_USERNAME="${AppDemoAccountName}"
export APP_DEMO_PASSWORD="${AppDemoPassword}"
export IS_CONSUMER=false
export ROS_DEPLOY=true
EOF
source ~/.bash_profile
curl -fsSL https://help-static-aliyun-doc.aliyuncs.com/install-script/rocketmq-transaction/install.sh|bash
${WaitConditionHandle.CurlCli} -d "{\"Data\" : \"Success\", \"status\" : \"SUCCESS\"}"
ConsumerRunCommand:
Type: ALIYUN::ECS::RunCommand
DependsOn:
- ConsumerGroup
- ProductRunCommand
Properties:
InstanceIds:
Fn::Select:
- 0
- Fn::GetAtt:
- EcsInstance
- InstanceIds
Type: RunShellScript
Sync: true
Timeout: 7200
CommandContent:
Fn::Sub: |-
#!/bin/bash
cat << EOF >> ~/.bash_profile
export MYSQL_HOST=${Database.InnerConnectionString}
export MYSQL_DB=rocketmq_transaction_db
export MYSQL_USER=${AccountName}
export MYSQL_PASSWORD=${DBPassword}
export APP_DEMO_ROCKETMQ_ENDPOINT=${RocketMQ.VpcEndpoint}
export APP_DEMO_ROCKETMQ_USERNAME=${RocketMQ.UserName}
export APP_DEMO_ROCKETMQ_PASSWORD=${RocketMQ.Password}
export APP_DEMO_USERNAME="${AppDemoAccountName}"
export APP_DEMO_PASSWORD="${AppDemoPassword}"
export IS_CONSUMER=true
export ROS_DEPLOY=true
EOF
source ~/.bash_profile
curl -fsSL https://help-static-aliyun-doc.aliyuncs.com/install-script/rocketmq-transaction/install.sh|bash
${WaitConditionHandle.CurlCli} -d "{\"Data\" : \"Success\", \"status\" : \"SUCCESS\"}"
Outputs:
AppDemoAccountName:
Description:
en: App demo username
zh-cn: 登录演示账户的用户名
Value:
Ref: AppDemoAccountName
Console.Url:
Label:
zh-cn: Web 访问地址
en: The Addresses of Web
Description:
zh-cn: Web 访问地址。
en: The Addresses of Web.
Value:
Fn::Sub:
- http://${ServerAddress}/login
- ServerAddress:
Fn::Select:
- 0
- Fn::Select:
- 1
- Fn::GetAtt:
- EcsInstance
- PublicIps
EcsLoginAddress:
Description:
zh-cn: ECS登录地址。
en: Ecs login address.
Value:
Fn::Sub:
- https://ecs-workbench.aliyun.com/?from=EcsConsole&instanceType=ecs®ionId=${Region}&instanceId=${InstanceId}
- InstanceId:
Fn::Select:
- 0
- Fn::Select:
- 1
- Fn::GetAtt:
- EcsInstance
- InstanceIds
Region:
Ref: ALIYUN::Region
Metadata:
ALIYUN::ROS::Interface:
ParameterGroups:
- Parameters:
- ZoneId
- InstanceType
- InstancePassword
Label:
default:
en: Ecs Configuration
zh-cn: ECS 实例配置
- Parameters:
- DBInstanceClass
- AccountName
- DBPassword
Label:
default:
en: RDS Configuration
zh-cn: RDS 实例配置
- Parameters:
- AppDemoAccountName
- AppDemoPassword
Label:
default:
en: App Demo Account Configuration
zh-cn: 登录演示账户配置
Hidden:
- CommonName
TemplateTags:
- acs:technical-solution:ai:通过RocketMQ事务消息实现分布式事务-tech_solu_154