@midwayjs/rabbitmq 3.4.4 → 3.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/framework.js +10 -4
- package/dist/mq.js +31 -23
- package/package.json +5 -5
- package/LICENSE +0 -21
package/dist/framework.js
CHANGED
|
@@ -26,10 +26,16 @@ let MidwayRabbitMQFramework = class MidwayRabbitMQFramework extends core_1.BaseF
|
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
async run() {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
try {
|
|
30
|
+
// init connection
|
|
31
|
+
await this.app.connect(this.configurationOptions.url, this.configurationOptions.socketOptions);
|
|
32
|
+
await this.loadSubscriber();
|
|
33
|
+
this.logger.info('Rabbitmq server start success');
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
this.app.close();
|
|
37
|
+
throw error;
|
|
38
|
+
}
|
|
33
39
|
}
|
|
34
40
|
async beforeStop() {
|
|
35
41
|
await this.app.close();
|
package/dist/mq.js
CHANGED
|
@@ -30,31 +30,39 @@ class RabbitMQServer extends events_1.EventEmitter {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
async connect(url, socketOptions) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
this.
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
33
|
+
this.connection = await amqp.connect(url, socketOptions);
|
|
34
|
+
// 监听在设置创建 channel 的错误
|
|
35
|
+
this.connection.on('error', err => {
|
|
36
|
+
if (err) {
|
|
37
|
+
if (err.err) {
|
|
38
|
+
err = err.err;
|
|
39
|
+
}
|
|
40
|
+
this.logger.error('Message Queue error', err);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
this.logger.info('Message Queue disconnected!');
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
await new Promise((resolve, reject) => {
|
|
47
|
+
// 监听 成功连接 的通知
|
|
48
|
+
this.connection.on('connect', () => {
|
|
49
|
+
this.logger.info('Message Queue connected!');
|
|
50
|
+
resolve();
|
|
51
|
+
});
|
|
52
|
+
// 监听 连接失败的错误 通知
|
|
53
|
+
this.connection.on('connectFailed', err => {
|
|
54
|
+
if (err) {
|
|
55
|
+
if (err.err) {
|
|
56
|
+
err = err.err;
|
|
49
57
|
}
|
|
50
|
-
|
|
51
|
-
}
|
|
58
|
+
this.logger.error('Message Queue disconnected', err);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
this.logger.info('Message Queue disconnected!');
|
|
62
|
+
}
|
|
63
|
+
reject(err);
|
|
52
64
|
});
|
|
53
|
-
}
|
|
54
|
-
catch (error) {
|
|
55
|
-
this.logger.error('Message Queue connect fail', error);
|
|
56
|
-
await this.closeConnection();
|
|
57
|
-
}
|
|
65
|
+
});
|
|
58
66
|
}
|
|
59
67
|
async createConsumer(listenerOptions, listenerCallback) {
|
|
60
68
|
const channelWrapper = this.connection.createChannel({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/rabbitmq",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.7",
|
|
4
4
|
"description": "Midway Framework for rabbitmq",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"typings": "index.d.ts",
|
|
@@ -25,13 +25,13 @@
|
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@midwayjs/decorator": "^3.4.4",
|
|
28
|
-
"@midwayjs/mock": "^3.4.
|
|
28
|
+
"@midwayjs/mock": "^3.4.7",
|
|
29
29
|
"@types/amqplib": "0.8.2",
|
|
30
|
-
"amqplib": "0.10.
|
|
30
|
+
"amqplib": "0.10.1",
|
|
31
31
|
"fs-extra": "10.0.1"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@midwayjs/core": "^3.4.
|
|
34
|
+
"@midwayjs/core": "^3.4.7",
|
|
35
35
|
"@midwayjs/logger": "^2.15.0",
|
|
36
36
|
"amqp-connection-manager": "4.1.3"
|
|
37
37
|
},
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"engines": {
|
|
48
48
|
"node": ">=12"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "3c60619a65c6776d99fbf0b30ac454d3cb6926b9"
|
|
51
51
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2013 - Now midwayjs
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|