@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.
@@ -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
- const channel = this._client.createChannel();
126
- for (const topic of args.topics) {
127
- const opts = this._config.queues?.[topic];
128
- if (opts)
129
- await channel.assertQueue(topic, opts);
130
- }
131
- for (const topic of args.topics) {
132
- await channel.assertQueue(topic);
133
- await channel
134
- .consume(topic, async (msg) => {
135
- if (!msg)
136
- return;
137
- await this.emitAsync('message', msg, topic).catch(noOp);
138
- try {
139
- await args.handler(channel, topic, msg);
140
- }
141
- catch (e) {
142
- this._emitError(e);
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
- /** Consume options */
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
  }
@@ -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
- const channel = this._client.createChannel();
122
- for (const topic of args.topics) {
123
- const opts = this._config.queues?.[topic];
124
- if (opts)
125
- await channel.assertQueue(topic, opts);
126
- }
127
- for (const topic of args.topics) {
128
- await channel.assertQueue(topic);
129
- await channel
130
- .consume(topic, async (msg) => {
131
- if (!msg)
132
- return;
133
- await this.emitAsync('message', msg, topic).catch(noOp);
134
- try {
135
- await args.handler(channel, topic, msg);
136
- }
137
- catch (e) {
138
- this._emitError(e);
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
- /** Consume options */
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.0",
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.0",
17
- "@opra/core": "^1.16.0",
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
  },