@seidor-cloud-produtos/orbit-backend-lib 2.0.70 → 2.0.72
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.
|
@@ -2,7 +2,6 @@ import amqp from 'amqplib';
|
|
|
2
2
|
import Handler from '../../../application/queue/handler';
|
|
3
3
|
import QueueConnection from '../../../application/queue/queue-connection';
|
|
4
4
|
import DomainEvent from '../../../domain/events/domain-event';
|
|
5
|
-
import QueueController from '../queue-controller';
|
|
6
5
|
import { AmqpQueueGetResult } from './types';
|
|
7
6
|
import { Logger } from '../../../application/logger';
|
|
8
7
|
interface SocketOptions {
|
|
@@ -19,7 +18,6 @@ export default class AmqpQueue implements QueueConnection {
|
|
|
19
18
|
private vHost;
|
|
20
19
|
private connection;
|
|
21
20
|
private messagesInMemory;
|
|
22
|
-
private controller;
|
|
23
21
|
private channels;
|
|
24
22
|
protected socketOptions?: SocketOptions;
|
|
25
23
|
constructor(socketOptions?: SocketOptions, uri?: string, logger?: Logger);
|
|
@@ -34,7 +32,6 @@ export default class AmqpQueue implements QueueConnection {
|
|
|
34
32
|
private publishToServer;
|
|
35
33
|
private static delayOperation;
|
|
36
34
|
createConsumers(queueName: string, configs: CreateConsumers): Promise<void>;
|
|
37
|
-
setController(controller?: QueueController): this;
|
|
38
35
|
static getInstance(vHost: string, socketOptions?: SocketOptions, uri?: string): Promise<AmqpQueue>;
|
|
39
36
|
private treatReconnection;
|
|
40
37
|
private reconnectionChannels;
|
|
@@ -43,5 +40,6 @@ export default class AmqpQueue implements QueueConnection {
|
|
|
43
40
|
type CreateConsumers = {
|
|
44
41
|
exchangeName: string;
|
|
45
42
|
exchangeType: 'direct' | 'fanout';
|
|
43
|
+
queueType?: 'classic' | 'quorum' | 'stream';
|
|
46
44
|
};
|
|
47
45
|
export {};
|
|
@@ -11,7 +11,6 @@ class AmqpQueue {
|
|
|
11
11
|
vHost;
|
|
12
12
|
connection;
|
|
13
13
|
messagesInMemory = [];
|
|
14
|
-
controller;
|
|
15
14
|
channels = new Map();
|
|
16
15
|
socketOptions;
|
|
17
16
|
constructor(socketOptions, uri = process.env.BROKER_AMQP, logger = console) {
|
|
@@ -171,6 +170,7 @@ class AmqpQueue {
|
|
|
171
170
|
arguments: {
|
|
172
171
|
'x-dead-letter-exchange': `${configs.exchangeName}.DLX`,
|
|
173
172
|
'x-dead-letter-routing-key': `${queueName || ''}.DLK`,
|
|
173
|
+
'x-queue-type': configs.queueType || 'classic',
|
|
174
174
|
},
|
|
175
175
|
durable: true,
|
|
176
176
|
deadLetterExchange: `${configs.exchangeName}.DLX`,
|
|
@@ -180,8 +180,13 @@ class AmqpQueue {
|
|
|
180
180
|
await channel.assertExchange(`${configs.exchangeName}.DLX`, configs.exchangeType || 'direct', {
|
|
181
181
|
durable: true,
|
|
182
182
|
});
|
|
183
|
+
const oneDayMs = 86400000;
|
|
183
184
|
await channel.assertQueue(`${queueName}.DLQ`, {
|
|
184
185
|
durable: true,
|
|
186
|
+
arguments: {
|
|
187
|
+
'x-message-ttl': 7 * oneDayMs,
|
|
188
|
+
'x-queue-type': configs.queueType || 'classic',
|
|
189
|
+
},
|
|
185
190
|
});
|
|
186
191
|
await channel.bindQueue(`${queueName}.DLQ`, `${configs.exchangeName}.DLX`, `${queueName || ''}.DLK`);
|
|
187
192
|
await channel.close();
|
|
@@ -193,12 +198,6 @@ class AmqpQueue {
|
|
|
193
198
|
});
|
|
194
199
|
}
|
|
195
200
|
}
|
|
196
|
-
setController(controller) {
|
|
197
|
-
if (controller) {
|
|
198
|
-
this.controller = controller;
|
|
199
|
-
}
|
|
200
|
-
return this;
|
|
201
|
-
}
|
|
202
201
|
static async getInstance(vHost, socketOptions, uri) {
|
|
203
202
|
if (AmqpQueue.instance && AmqpQueue.instance.vHost === vHost) {
|
|
204
203
|
return AmqpQueue.instance;
|