amqp-extension 3.1.0 → 3.2.0
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/CHANGELOG.md +19 -0
- package/dist/consume/utils.js +0 -1
- package/dist/module.d.ts +2 -1
- package/dist/module.js +12 -4
- package/dist/publish/utils.js +0 -1
- package/dist/type.d.ts +0 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
# [3.2.0](https://github.com/Tada5hi/amqp-extension/compare/v3.1.1...v3.2.0) (2024-03-11)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* remove unnecessary alias option ([8027d0a](https://github.com/Tada5hi/amqp-extension/commit/8027d0afb2063e5d0387dacf26cd77444dc933e4))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* allways close channel after publishing ([a9b300f](https://github.com/Tada5hi/amqp-extension/commit/a9b300f6ab64d176a656cf9fc485f31a36168a7f))
|
|
12
|
+
|
|
13
|
+
## [3.1.1](https://github.com/Tada5hi/amqp-extension/compare/v3.1.0...v3.1.1) (2024-03-07)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* don't register consumer multiple times ([b45defa](https://github.com/Tada5hi/amqp-extension/commit/b45defa4dbd5a7abf6d2568586e2ff5bf2e62d16))
|
|
19
|
+
|
|
1
20
|
# [3.1.0](https://github.com/Tada5hi/amqp-extension/compare/v3.0.0...v3.1.0) (2024-03-06)
|
|
2
21
|
|
|
3
22
|
|
package/dist/consume/utils.js
CHANGED
package/dist/module.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Connection } from 'amqplib';
|
|
1
|
+
import type { Channel, Connection } from 'amqplib';
|
|
2
2
|
import type { Config, ConfigInput } from './config';
|
|
3
3
|
import type { ConsumeHandlers } from './consume';
|
|
4
4
|
import type { PublishOptionsExtended } from './publish';
|
|
@@ -16,6 +16,7 @@ export declare class Client {
|
|
|
16
16
|
protected createConnection(): Promise<Connection>;
|
|
17
17
|
useConnection(): Promise<Connection>;
|
|
18
18
|
protected recreateConsumers(): Promise<void>;
|
|
19
|
+
protected createConsumer(options: ConsumeOptions, handlers: ConsumeHandlers): Promise<Channel>;
|
|
19
20
|
consume(options: ConsumeOptions, handlers: ConsumeHandlers): Promise<void>;
|
|
20
21
|
publish(options: PublishOptionsExtended): Promise<boolean>;
|
|
21
22
|
}
|
package/dist/module.js
CHANGED
|
@@ -64,10 +64,10 @@ class Client {
|
|
|
64
64
|
}
|
|
65
65
|
async recreateConsumers() {
|
|
66
66
|
for (let i = 0; i < this.consumers.length; i++) {
|
|
67
|
-
await this.
|
|
67
|
+
await this.createConsumer(this.consumers[i].options, this.consumers[i].handlers);
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
-
async
|
|
70
|
+
async createConsumer(options, handlers) {
|
|
71
71
|
const connection = await this.useConnection();
|
|
72
72
|
const channel = await connection.createChannel();
|
|
73
73
|
options = (0, smob_1.merge)(options, this.config.consume);
|
|
@@ -120,6 +120,10 @@ class Client {
|
|
|
120
120
|
}
|
|
121
121
|
};
|
|
122
122
|
await channel.consume(queueName, (message) => handleMessage(message), (0, consume_1.buildDriverConsumeOptions)(options));
|
|
123
|
+
return channel;
|
|
124
|
+
}
|
|
125
|
+
async consume(options, handlers) {
|
|
126
|
+
await this.createConsumer(options, handlers);
|
|
123
127
|
this.consumers.push({
|
|
124
128
|
options,
|
|
125
129
|
handlers,
|
|
@@ -153,10 +157,12 @@ class Client {
|
|
|
153
157
|
if (typeof exchangeOptions.routingKey === 'undefined') {
|
|
154
158
|
throw new Error('The routingKey can not be empty if a non default exchange is selected.');
|
|
155
159
|
}
|
|
156
|
-
|
|
160
|
+
const published = channel.publish(this.config.exchange.name, exchangeOptions.routingKey, buffer, (0, publish_1.buildDriverPublishOptions)({
|
|
157
161
|
persistent: true,
|
|
158
162
|
...options,
|
|
159
163
|
}));
|
|
164
|
+
await channel.close();
|
|
165
|
+
return published;
|
|
160
166
|
}
|
|
161
167
|
// publish to default exchange
|
|
162
168
|
const queueName = options.queueName ||
|
|
@@ -167,10 +173,12 @@ class Client {
|
|
|
167
173
|
await channel.assertQueue(queueName, {
|
|
168
174
|
durable: true,
|
|
169
175
|
});
|
|
170
|
-
|
|
176
|
+
const published = channel.sendToQueue(queueName, buffer, (0, publish_1.buildDriverPublishOptions)({
|
|
171
177
|
persistent: true,
|
|
172
178
|
...options,
|
|
173
179
|
}));
|
|
180
|
+
await channel.close();
|
|
181
|
+
return published;
|
|
174
182
|
}
|
|
175
183
|
}
|
|
176
184
|
exports.Client = Client;
|
package/dist/publish/utils.js
CHANGED
package/dist/type.d.ts
CHANGED
package/package.json
CHANGED