@opra/rabbitmq 1.16.0 → 1.16.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/cjs/rabbitmq-adapter.js +26 -27
- package/esm/rabbitmq-adapter.js +26 -27
- package/package.json +3 -3
package/cjs/rabbitmq-adapter.js
CHANGED
|
@@ -122,34 +122,33 @@ class RabbitmqAdapter extends core_1.PlatformAdapter {
|
|
|
122
122
|
this.logger?.info?.(`Connected RabbitMQ at ${connectionOptions.urls}`);
|
|
123
123
|
for (const args of handlerArgs) {
|
|
124
124
|
/** Create channel per operation */
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
125
|
+
this._client.createChannel({
|
|
126
|
+
setup: async (channel) => {
|
|
127
|
+
for (const topic of args.topics) {
|
|
128
|
+
const opts = this._config.queues?.[topic];
|
|
129
|
+
await channel.assertQueue(topic, opts);
|
|
130
|
+
await channel
|
|
131
|
+
.consume(topic, async (msg) => {
|
|
132
|
+
if (!msg)
|
|
133
|
+
return;
|
|
134
|
+
await this.emitAsync('message', msg, topic).catch(noOp);
|
|
135
|
+
try {
|
|
136
|
+
await args.handler(channel, topic, msg);
|
|
137
|
+
}
|
|
138
|
+
catch (e) {
|
|
139
|
+
this._emitError(e);
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
/** Consume options */
|
|
143
|
+
args.operationConfig.consumer)
|
|
144
|
+
.catch(e => {
|
|
145
|
+
this._emitError(e);
|
|
146
|
+
throw e;
|
|
147
|
+
});
|
|
148
|
+
this.logger?.info?.(`Subscribed to topic${args.topics.length > 1 ? 's' : ''} "${args.topics}"`);
|
|
143
149
|
}
|
|
144
|
-
},
|
|
145
|
-
|
|
146
|
-
args.operationConfig.consumer)
|
|
147
|
-
.catch(e => {
|
|
148
|
-
this._emitError(e);
|
|
149
|
-
throw e;
|
|
150
|
-
});
|
|
151
|
-
this.logger?.info?.(`Subscribed to topic${args.topics.length > 1 ? 's' : ''} "${args.topics}"`);
|
|
152
|
-
}
|
|
150
|
+
},
|
|
151
|
+
});
|
|
153
152
|
}
|
|
154
153
|
this._status = 'started';
|
|
155
154
|
}
|
package/esm/rabbitmq-adapter.js
CHANGED
|
@@ -118,34 +118,33 @@ export class RabbitmqAdapter extends PlatformAdapter {
|
|
|
118
118
|
this.logger?.info?.(`Connected RabbitMQ at ${connectionOptions.urls}`);
|
|
119
119
|
for (const args of handlerArgs) {
|
|
120
120
|
/** Create channel per operation */
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
121
|
+
this._client.createChannel({
|
|
122
|
+
setup: async (channel) => {
|
|
123
|
+
for (const topic of args.topics) {
|
|
124
|
+
const opts = this._config.queues?.[topic];
|
|
125
|
+
await channel.assertQueue(topic, opts);
|
|
126
|
+
await channel
|
|
127
|
+
.consume(topic, async (msg) => {
|
|
128
|
+
if (!msg)
|
|
129
|
+
return;
|
|
130
|
+
await this.emitAsync('message', msg, topic).catch(noOp);
|
|
131
|
+
try {
|
|
132
|
+
await args.handler(channel, topic, msg);
|
|
133
|
+
}
|
|
134
|
+
catch (e) {
|
|
135
|
+
this._emitError(e);
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
/** Consume options */
|
|
139
|
+
args.operationConfig.consumer)
|
|
140
|
+
.catch(e => {
|
|
141
|
+
this._emitError(e);
|
|
142
|
+
throw e;
|
|
143
|
+
});
|
|
144
|
+
this.logger?.info?.(`Subscribed to topic${args.topics.length > 1 ? 's' : ''} "${args.topics}"`);
|
|
139
145
|
}
|
|
140
|
-
},
|
|
141
|
-
|
|
142
|
-
args.operationConfig.consumer)
|
|
143
|
-
.catch(e => {
|
|
144
|
-
this._emitError(e);
|
|
145
|
-
throw e;
|
|
146
|
-
});
|
|
147
|
-
this.logger?.info?.(`Subscribed to topic${args.topics.length > 1 ? 's' : ''} "${args.topics}"`);
|
|
148
|
-
}
|
|
146
|
+
},
|
|
147
|
+
});
|
|
149
148
|
}
|
|
150
149
|
this._status = 'started';
|
|
151
150
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/rabbitmq",
|
|
3
|
-
"version": "1.16.
|
|
3
|
+
"version": "1.16.1",
|
|
4
4
|
"description": "Opra RabbitMQ package",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"valgen": "^5.15.0"
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
16
|
-
"@opra/common": "^1.16.
|
|
17
|
-
"@opra/core": "^1.16.
|
|
16
|
+
"@opra/common": "^1.16.1",
|
|
17
|
+
"@opra/core": "^1.16.1",
|
|
18
18
|
"amqp-connection-manager": "^4.1.14",
|
|
19
19
|
"amqplib": "^0.10.7"
|
|
20
20
|
},
|