@midwayjs/rabbitmq 3.19.2 → 4.0.0-alpha.1
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/configuration.js +2 -2
- package/dist/framework.d.ts +1 -2
- package/dist/framework.js +5 -8
- package/dist/mq.js +3 -5
- package/package.json +6 -6
package/dist/configuration.js
CHANGED
|
@@ -11,7 +11,8 @@ const core_1 = require("@midwayjs/core");
|
|
|
11
11
|
let RabbitMQConfiguration = class RabbitMQConfiguration {
|
|
12
12
|
async onReady() { }
|
|
13
13
|
};
|
|
14
|
-
RabbitMQConfiguration =
|
|
14
|
+
exports.RabbitMQConfiguration = RabbitMQConfiguration;
|
|
15
|
+
exports.RabbitMQConfiguration = RabbitMQConfiguration = __decorate([
|
|
15
16
|
(0, core_1.Configuration)({
|
|
16
17
|
namespace: 'rabbitMQ',
|
|
17
18
|
importConfigs: [
|
|
@@ -23,5 +24,4 @@ RabbitMQConfiguration = __decorate([
|
|
|
23
24
|
],
|
|
24
25
|
})
|
|
25
26
|
], RabbitMQConfiguration);
|
|
26
|
-
exports.RabbitMQConfiguration = RabbitMQConfiguration;
|
|
27
27
|
//# sourceMappingURL=configuration.js.map
|
package/dist/framework.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseFramework } from '@midwayjs/core';
|
|
2
2
|
import { IMidwayRabbitMQApplication, IMidwayRabbitMQConfigurationOptions, IMidwayRabbitMQContext } from './interface';
|
|
3
3
|
export declare class MidwayRabbitMQFramework extends BaseFramework<IMidwayRabbitMQApplication, IMidwayRabbitMQContext, IMidwayRabbitMQConfigurationOptions> {
|
|
4
4
|
app: IMidwayRabbitMQApplication;
|
|
@@ -7,7 +7,6 @@ export declare class MidwayRabbitMQFramework extends BaseFramework<IMidwayRabbit
|
|
|
7
7
|
applicationInitialize(options: any): Promise<void>;
|
|
8
8
|
run(): Promise<void>;
|
|
9
9
|
protected beforeStop(): Promise<void>;
|
|
10
|
-
getFrameworkType(): MidwayFrameworkType;
|
|
11
10
|
private loadSubscriber;
|
|
12
11
|
getFrameworkName(): string;
|
|
13
12
|
}
|
package/dist/framework.js
CHANGED
|
@@ -39,13 +39,10 @@ let MidwayRabbitMQFramework = class MidwayRabbitMQFramework extends core_1.BaseF
|
|
|
39
39
|
async beforeStop() {
|
|
40
40
|
await this.app.close();
|
|
41
41
|
}
|
|
42
|
-
getFrameworkType() {
|
|
43
|
-
return core_1.MidwayFrameworkType.MS_RABBITMQ;
|
|
44
|
-
}
|
|
45
42
|
async loadSubscriber() {
|
|
46
43
|
// create channel
|
|
47
|
-
const subscriberModules =
|
|
48
|
-
const metadata =
|
|
44
|
+
const subscriberModules = core_1.DecoratorManager.listModule(core_1.MS_CONSUMER_KEY, module => {
|
|
45
|
+
const metadata = core_1.MetadataManager.getOwnMetadata(core_1.MS_CONSUMER_KEY, module);
|
|
49
46
|
return metadata.type === core_1.MSListenerType.RABBITMQ;
|
|
50
47
|
});
|
|
51
48
|
for (const module of subscriberModules) {
|
|
@@ -87,11 +84,11 @@ let MidwayRabbitMQFramework = class MidwayRabbitMQFramework extends core_1.BaseF
|
|
|
87
84
|
}
|
|
88
85
|
}
|
|
89
86
|
getFrameworkName() {
|
|
90
|
-
return '
|
|
87
|
+
return 'rabbitmq';
|
|
91
88
|
}
|
|
92
89
|
};
|
|
93
|
-
MidwayRabbitMQFramework =
|
|
90
|
+
exports.MidwayRabbitMQFramework = MidwayRabbitMQFramework;
|
|
91
|
+
exports.MidwayRabbitMQFramework = MidwayRabbitMQFramework = __decorate([
|
|
94
92
|
(0, core_1.Framework)()
|
|
95
93
|
], MidwayRabbitMQFramework);
|
|
96
|
-
exports.MidwayRabbitMQFramework = MidwayRabbitMQFramework;
|
|
97
94
|
//# sourceMappingURL=framework.js.map
|
package/dist/mq.js
CHANGED
|
@@ -8,12 +8,11 @@ const amqp = require("amqp-connection-manager");
|
|
|
8
8
|
const events_1 = require("events");
|
|
9
9
|
class RabbitMQServer extends events_1.EventEmitter {
|
|
10
10
|
constructor(options = {}) {
|
|
11
|
-
var _a;
|
|
12
11
|
super();
|
|
13
12
|
this.channelManagerSet = new Set();
|
|
14
13
|
this.connection = null;
|
|
15
14
|
this.logger = options.logger;
|
|
16
|
-
this.reconnectTime =
|
|
15
|
+
this.reconnectTime = options.reconnectTime ?? 10 * 1000;
|
|
17
16
|
this.bindError();
|
|
18
17
|
}
|
|
19
18
|
bindError() {
|
|
@@ -67,18 +66,17 @@ class RabbitMQServer extends events_1.EventEmitter {
|
|
|
67
66
|
async createConsumer(listenerOptions, listenerCallback) {
|
|
68
67
|
const channelWrapper = this.connection.createChannel({
|
|
69
68
|
setup: (channel) => {
|
|
70
|
-
var _a, _b, _c;
|
|
71
69
|
// `channel` here is a regular amqplib `ConfirmChannel`.
|
|
72
70
|
const channelHandlers = [];
|
|
73
71
|
// create queue
|
|
74
72
|
channelHandlers.push(channel.assertQueue(listenerOptions.queueName, Object.assign({ durable: true }, listenerOptions)));
|
|
75
73
|
if (listenerOptions.exchange) {
|
|
76
74
|
// create exchange
|
|
77
|
-
channelHandlers.push(channel.assertExchange(listenerOptions.exchange,
|
|
75
|
+
channelHandlers.push(channel.assertExchange(listenerOptions.exchange, listenerOptions.exchangeOptions?.type ?? 'topic', listenerOptions.exchangeOptions));
|
|
78
76
|
// bind exchange and queue
|
|
79
77
|
channelHandlers.push(channel.bindQueue(listenerOptions.queueName, listenerOptions.exchange, listenerOptions.routingKey || listenerOptions.pattern, listenerOptions.exchangeOptions));
|
|
80
78
|
}
|
|
81
|
-
channelHandlers.push(channel.prefetch(
|
|
79
|
+
channelHandlers.push(channel.prefetch(listenerOptions.prefetch ?? 1));
|
|
82
80
|
// listen queue
|
|
83
81
|
channelHandlers.push(channel.consume(listenerOptions.queueName, async (msg) => {
|
|
84
82
|
await listenerCallback(msg, channel, channelWrapper);
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/rabbitmq",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-alpha.1",
|
|
4
4
|
"description": "Midway Framework for rabbitmq",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "tsc",
|
|
9
|
-
"test": "node
|
|
10
|
-
"cov": "node
|
|
9
|
+
"test": "node -r ts-node/register ../../node_modules/jest/bin/jest.js --runInBand",
|
|
10
|
+
"cov": "node -r ts-node/register ../../node_modules/jest/bin/jest.js --runInBand --coverage --forceExit",
|
|
11
11
|
"lint:fix": "../../node_modules/.bin/mwts fix"
|
|
12
12
|
},
|
|
13
13
|
"keywords": [
|
|
@@ -24,13 +24,13 @@
|
|
|
24
24
|
],
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@midwayjs/
|
|
27
|
+
"@midwayjs/core": "workspace:^",
|
|
28
28
|
"@types/amqplib": "0.10.6",
|
|
29
29
|
"amqplib": "0.10.5",
|
|
30
30
|
"fs-extra": "11.2.0"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@midwayjs/core": "^
|
|
33
|
+
"@midwayjs/core": "^4.0.0-alpha.1",
|
|
34
34
|
"amqp-connection-manager": "4.1.14"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"engines": {
|
|
46
46
|
"node": ">=12"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "14bb4da91805a1cf52f190c0d37a74b395dd6372"
|
|
49
49
|
}
|