rabbitmq-with-retry-and-dlq 1.0.24 → 1.0.26
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/README.md +235 -139
- package/dist/consumerMq.d.ts +90 -3
- package/dist/consumerMq.d.ts.map +1 -1
- package/dist/consumerMq.js +319 -71
- package/dist/consumerMq.js.map +1 -1
- package/dist/publisherMq.d.ts +4 -71
- package/dist/publisherMq.d.ts.map +1 -1
- package/dist/publisherMq.js +72 -251
- package/dist/publisherMq.js.map +1 -1
- package/dist/types.d.ts +12 -12
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +7 -1
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
- package/dist/test-connection.d.ts +0 -2
- package/dist/test-connection.d.ts.map +0 -1
- package/dist/test-connection.js +0 -38
- package/dist/test-connection.js.map +0 -1
- package/dist/test-wrong-url.d.ts +0 -2
- package/dist/test-wrong-url.d.ts.map +0 -1
- package/dist/test-wrong-url.js +0 -34
- package/dist/test-wrong-url.js.map +0 -1
- package/dist/test.d.ts +0 -19
- package/dist/test.d.ts.map +0 -1
- package/dist/test.js +0 -446
- package/dist/test.js.map +0 -1
package/dist/consumerMq.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ declare class RabbitMQConsumer extends EventEmitter {
|
|
|
9
9
|
private reconnectIntervalSeconds;
|
|
10
10
|
private connectionTimeoutMs;
|
|
11
11
|
private initializationPromise?;
|
|
12
|
+
private queueRetryConfigs;
|
|
12
13
|
/**
|
|
13
14
|
* Create a new RabbitMQ Consumer
|
|
14
15
|
* @param options - Connection URL string or ConnectionOptions object
|
|
@@ -76,8 +77,11 @@ declare class RabbitMQConsumer extends EventEmitter {
|
|
|
76
77
|
* await consumer.assertQueues(['orders-worker', 'payments-worker']);
|
|
77
78
|
*
|
|
78
79
|
* @example
|
|
79
|
-
* // Assert queue with
|
|
80
|
+
* // Assert queue with exchange binding and retry config
|
|
80
81
|
* await consumer.assertQueues('orders-worker', {
|
|
82
|
+
* exchangeName: 'orders',
|
|
83
|
+
* exchangeType: 'direct',
|
|
84
|
+
* routingKey: 'order.created',
|
|
81
85
|
* retryConfig: { maxRetries: 3, retryDelayMs: 5000 }
|
|
82
86
|
* });
|
|
83
87
|
*/
|
|
@@ -85,12 +89,44 @@ declare class RabbitMQConsumer extends EventEmitter {
|
|
|
85
89
|
durable?: boolean;
|
|
86
90
|
exclusive?: boolean;
|
|
87
91
|
autoDelete?: boolean;
|
|
92
|
+
exchangeName?: string;
|
|
93
|
+
exchangeType?: 'direct' | 'topic' | 'fanout' | 'headers';
|
|
94
|
+
routingKey?: string;
|
|
88
95
|
retryConfig?: RetryConfig;
|
|
89
96
|
}): Promise<void>;
|
|
90
97
|
/**
|
|
91
|
-
*
|
|
98
|
+
* Delete queues (Best Practice for cleanup/testing)
|
|
99
|
+
* Can be called with a single queue name or multiple queue names
|
|
100
|
+
* Also deletes associated retry and DLQ queues if they exist
|
|
101
|
+
*
|
|
102
|
+
* @param queueNames - Single queue name (string) or array of queue names
|
|
103
|
+
* @param options - Delete options (includeRetry, includeDLQ)
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* // Delete a single queue
|
|
107
|
+
* await consumer.deleteQueues('orders');
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* // Delete multiple queues
|
|
111
|
+
* await consumer.deleteQueues(['orders', 'payments', 'notifications']);
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* // Delete queue without retry/DLQ queues
|
|
115
|
+
* await consumer.deleteQueues('orders', {
|
|
116
|
+
* includeRetry: false,
|
|
117
|
+
* includeDLQ: false
|
|
118
|
+
* });
|
|
119
|
+
*/
|
|
120
|
+
deleteQueues(queueNames: string | string[], options?: {
|
|
121
|
+
/** Whether to delete associated retry queue (default: true) */
|
|
122
|
+
includeRetry?: boolean;
|
|
123
|
+
/** Whether to delete associated DLQ (default: true) */
|
|
124
|
+
includeDLQ?: boolean;
|
|
125
|
+
}): Promise<void>;
|
|
126
|
+
/**
|
|
127
|
+
* Setup Dead Letter Queue (DLQ) infrastructure for a queue with retry mechanism
|
|
92
128
|
*/
|
|
93
|
-
private
|
|
129
|
+
private setupDLQInfrastructure;
|
|
94
130
|
/**
|
|
95
131
|
* Bind a queue to an exchange with a routing key (Best Practice for Consumers)
|
|
96
132
|
* Consumers decide which exchanges/routing keys they want to subscribe to
|
|
@@ -176,10 +212,61 @@ declare class RabbitMQConsumer extends EventEmitter {
|
|
|
176
212
|
private calculateRetryDelay;
|
|
177
213
|
/**
|
|
178
214
|
* Consume messages from a queue with automatic retry and DLQ handling
|
|
215
|
+
*
|
|
216
|
+
* Note: Queue should be set up separately before consuming:
|
|
217
|
+
* - Use assertQueues() to create queue with exchange binding
|
|
218
|
+
* - Use setupQueue() for complete setup with multiple routing keys
|
|
219
|
+
* - Use bindQueue() to add additional routing key bindings
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* // Step 1: Setup queue with exchange and routing keys
|
|
223
|
+
* await consumer.setupQueue({
|
|
224
|
+
* queueName: 'orders',
|
|
225
|
+
* exchangeName: 'orders',
|
|
226
|
+
* exchangeType: 'topic',
|
|
227
|
+
* routingKeys: ['order.created', 'order.updated'],
|
|
228
|
+
* retryConfig: { maxRetries: 5 }
|
|
229
|
+
* });
|
|
230
|
+
*
|
|
231
|
+
* // Step 2: Consume (queue already set up)
|
|
232
|
+
* await consumer.consumeQueue({
|
|
233
|
+
* queueName: 'orders',
|
|
234
|
+
* onMessage: async (message) => {
|
|
235
|
+
* await processOrder(message);
|
|
236
|
+
* }
|
|
237
|
+
* });
|
|
238
|
+
*
|
|
239
|
+
* @example
|
|
240
|
+
* // Direct queue consumption (no exchange)
|
|
241
|
+
* await consumer.assertQueues('simple-queue');
|
|
242
|
+
* await consumer.consumeQueue({
|
|
243
|
+
* queueName: 'simple-queue',
|
|
244
|
+
* onMessage: async (message) => { ... }
|
|
245
|
+
* });
|
|
179
246
|
*/
|
|
180
247
|
consumeQueue<T = any>(config: ConsumeConfig<T>): Promise<void>;
|
|
181
248
|
/**
|
|
182
249
|
* Consume from multiple queues with the same connection
|
|
250
|
+
* Note: Queues should be set up separately before consuming
|
|
251
|
+
*
|
|
252
|
+
* @example
|
|
253
|
+
* // Setup queues first
|
|
254
|
+
* await consumer.setupQueue({ queueName: 'orders', ... });
|
|
255
|
+
* await consumer.setupQueue({ queueName: 'payments', ... });
|
|
256
|
+
*
|
|
257
|
+
* // Then consume from all
|
|
258
|
+
* await consumer.consumeMultipleQueues({
|
|
259
|
+
* queues: [
|
|
260
|
+
* {
|
|
261
|
+
* queueName: 'orders',
|
|
262
|
+
* onMessage: async (msg) => { ... }
|
|
263
|
+
* },
|
|
264
|
+
* {
|
|
265
|
+
* queueName: 'payments',
|
|
266
|
+
* onMessage: async (msg) => { ... }
|
|
267
|
+
* }
|
|
268
|
+
* ]
|
|
269
|
+
* });
|
|
183
270
|
*/
|
|
184
271
|
consumeMultipleQueues<T = any>(config: MultiQueueConsumeConfig<T>): Promise<void>;
|
|
185
272
|
/**
|
package/dist/consumerMq.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consumerMq.d.ts","sourceRoot":"","sources":["../consumerMq.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,
|
|
1
|
+
{"version":3,"file":"consumerMq.d.ts","sourceRoot":"","sources":["../consumerMq.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EASL,aAAa,EACb,WAAW,EACX,uBAAuB,EAIvB,iBAAiB,EACjB,WAAW,EACZ,MAAM,SAAS,CAAC;AAGjB,cAAM,gBAAiB,SAAQ,YAAY;IACzC,OAAO,CAAC,UAAU,CAAC,CAA6B;IAChD,OAAO,CAAC,OAAO,CAAC,CAAsB;IAC/B,SAAS,EAAE,MAAM,CAAC;IACzB,OAAO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