@seidor-cloud-produtos/orbit-backend-lib 2.0.73 → 2.0.74
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.
|
@@ -31,7 +31,12 @@ export default class AmqpQueue implements QueueConnection {
|
|
|
31
31
|
publish(exchangeName: string, domainEvent: DomainEvent, configs?: Record<string, any>): Promise<void>;
|
|
32
32
|
private publishToServer;
|
|
33
33
|
private static delayOperation;
|
|
34
|
+
/**
|
|
35
|
+
*
|
|
36
|
+
* @deprecated Use createQueues() instead.
|
|
37
|
+
*/
|
|
34
38
|
createConsumers(queueName: string, configs: CreateConsumers): Promise<void>;
|
|
39
|
+
createQueues(queueName: string, configs: CreateConsumers): Promise<void>;
|
|
35
40
|
static getInstance(vHost?: string, socketOptions?: SocketOptions, uri?: string): Promise<AmqpQueue>;
|
|
36
41
|
private treatReconnection;
|
|
37
42
|
private reconnectionChannels;
|
|
@@ -41,5 +46,6 @@ type CreateConsumers = {
|
|
|
41
46
|
exchangeName: string;
|
|
42
47
|
exchangeType: 'direct' | 'fanout';
|
|
43
48
|
queueType?: 'classic' | 'quorum' | 'stream';
|
|
49
|
+
dlqTTLms?: number | null;
|
|
44
50
|
};
|
|
45
51
|
export {};
|
|
@@ -164,6 +164,10 @@ class AmqpQueue {
|
|
|
164
164
|
await new Promise(resolve => setTimeout(resolve, timeoutMs));
|
|
165
165
|
return new infra_error_1.default('Timeout with rabbitMQ server!');
|
|
166
166
|
}
|
|
167
|
+
/**
|
|
168
|
+
*
|
|
169
|
+
* @deprecated Use createQueues() instead.
|
|
170
|
+
*/
|
|
167
171
|
async createConsumers(queueName, configs) {
|
|
168
172
|
try {
|
|
169
173
|
const channel = await this.connection.createChannel();
|
|
@@ -188,7 +192,7 @@ class AmqpQueue {
|
|
|
188
192
|
await channel.assertQueue(`${queueName}.DLQ`, {
|
|
189
193
|
durable: true,
|
|
190
194
|
arguments: {
|
|
191
|
-
'x-message-ttl':
|
|
195
|
+
...(configs.dlqTTLms ? { 'x-message-ttl': configs.dlqTTLms } : {}),
|
|
192
196
|
'x-queue-type': configs.queueType || 'classic',
|
|
193
197
|
},
|
|
194
198
|
});
|
|
@@ -202,6 +206,16 @@ class AmqpQueue {
|
|
|
202
206
|
});
|
|
203
207
|
}
|
|
204
208
|
}
|
|
209
|
+
async createQueues(queueName, configs) {
|
|
210
|
+
const buildedConfigs = {
|
|
211
|
+
...configs,
|
|
212
|
+
};
|
|
213
|
+
if (buildedConfigs.dlqTTLms === undefined) {
|
|
214
|
+
const sevenDaysInMs = 604800000;
|
|
215
|
+
buildedConfigs.dlqTTLms = sevenDaysInMs;
|
|
216
|
+
}
|
|
217
|
+
return await this.createConsumers(queueName, configs);
|
|
218
|
+
}
|
|
205
219
|
static async getInstance(vHost = '', socketOptions, uri) {
|
|
206
220
|
if (AmqpQueue.instance && AmqpQueue.instance.vHost === vHost) {
|
|
207
221
|
return AmqpQueue.instance;
|