rabbitmq-with-retry-and-dlq 1.0.7 → 1.0.8

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 CHANGED
@@ -14,7 +14,7 @@ A production-ready TypeScript RabbitMQ library with automatic retry, exponential
14
14
  ## Installation
15
15
 
16
16
  ```bash
17
- npm install rabbitmq-with-retry-and-dlq amqp-connection-manager amqplib
17
+ npm install rabbitmq-with-retry-and-dlq
18
18
  ```
19
19
 
20
20
  ---
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rabbitmq-with-retry-and-dlq",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "RabbitMQ implementation with dynamic retry logic and Dead Letter Queue support",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,13 +0,0 @@
1
- /**
2
- * Simple Test File for Package Testing
3
- *
4
- * This file tests the package as if it's installed from npm.
5
- * Run: ts-node test-package.ts
6
- *
7
- * Make sure to:
8
- * 1. Build the package first: npm run build
9
- * 2. Install the package: npm install (or npm link for local testing)
10
- * 3. Set RABBITMQ_URL environment variable
11
- */
12
- export {};
13
- //# sourceMappingURL=test-package.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"test-package.d.ts","sourceRoot":"","sources":["../test-package.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG"}
@@ -1,131 +0,0 @@
1
- "use strict";
2
- /**
3
- * Simple Test File for Package Testing
4
- *
5
- * This file tests the package as if it's installed from npm.
6
- * Run: ts-node test-package.ts
7
- *
8
- * Make sure to:
9
- * 1. Build the package first: npm run build
10
- * 2. Install the package: npm install (or npm link for local testing)
11
- * 3. Set RABBITMQ_URL environment variable
12
- */
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- // Import from the published package (install it first: npm install rabbitmq-with-retry-and-dlq)
15
- const rabbitmq_with_retry_and_dlq_1 = require("rabbitmq-with-retry-and-dlq");
16
- const RABBITMQ_URL = process.env.RABBITMQ_URL || 'amqp://localhost';
17
- async function testConnection() {
18
- console.log('='.repeat(60));
19
- console.log('RABBITMQ PACKAGE TEST');
20
- console.log('='.repeat(60));
21
- console.log(`Connecting to: ${RABBITMQ_URL}\n`);
22
- try {
23
- // 1. Initialize RabbitMQ
24
- console.log('1. Initializing RabbitMQ connection...');
25
- await (0, rabbitmq_with_retry_and_dlq_1.initializeRabbitMQ)(RABBITMQ_URL);
26
- console.log('✓ Connected successfully\n');
27
- // 2. Set up error handler
28
- console.log('2. Setting up error handler...');
29
- rabbitmq_with_retry_and_dlq_1.consumer.on('error', (errorEvent) => {
30
- console.error('❌ RabbitMQ Error:', {
31
- type: errorEvent.type,
32
- queueName: errorEvent.queueName,
33
- error: errorEvent.error,
34
- });
35
- });
36
- console.log('✓ Error handler set up\n');
37
- // 3. Assert queues
38
- console.log('3. Asserting queues...');
39
- await rabbitmq_with_retry_and_dlq_1.publisher.assertQueues('test_queue', {
40
- durable: true,
41
- retryConfig: {
42
- maxRetries: 3,
43
- retryDelayMs: 1000,
44
- backoffStrategy: 'exponential',
45
- },
46
- });
47
- console.log('✓ Queue asserted: test_queue\n');
48
- // 4. Assert queue with exchange
49
- console.log('4. Asserting queue with exchange...');
50
- await rabbitmq_with_retry_and_dlq_1.publisher.assertQueues('test_exchange_queue', {
51
- durable: true,
52
- exchangeName: 'test_exchange',
53
- exchangeType: 'direct',
54
- routingKey: 'test.routing.key',
55
- retryConfig: {
56
- maxRetries: 2,
57
- retryDelayMs: 2000,
58
- backoffStrategy: 'linear',
59
- },
60
- });
61
- console.log('✓ Queue with exchange asserted: test_exchange_queue\n');
62
- // 5. Check connection status
63
- console.log('5. Checking connection status...');
64
- console.log(` Publisher connected: ${rabbitmq_with_retry_and_dlq_1.publisher.isPublisherConnected()}`);
65
- console.log(` Consumer connected: ${rabbitmq_with_retry_and_dlq_1.consumer.isConsumerConnected()}`);
66
- console.log('✓ Connection status checked\n');
67
- // 6. Publish a test message
68
- console.log('6. Publishing test message...');
69
- await rabbitmq_with_retry_and_dlq_1.publisher.publishToQueue({
70
- queueName: 'test_queue',
71
- message: {
72
- testId: 'test-' + Date.now(),
73
- message: 'Hello from test!',
74
- timestamp: new Date().toISOString(),
75
- },
76
- });
77
- console.log('✓ Message published to test_queue\n');
78
- // 7. Set up consumer
79
- console.log('7. Setting up consumer...');
80
- let messageReceived = false;
81
- await rabbitmq_with_retry_and_dlq_1.consumer.consumeQueue({
82
- queueName: 'test_queue',
83
- onMessage: async (message) => {
84
- console.log('✓ Message received:', message);
85
- messageReceived = true;
86
- },
87
- options: {
88
- prefetch: 1,
89
- },
90
- });
91
- console.log('✓ Consumer set up, waiting for message...\n');
92
- // Wait for message to be processed
93
- await new Promise((resolve) => setTimeout(resolve, 2000));
94
- if (messageReceived) {
95
- console.log('✓ Test message processed successfully\n');
96
- }
97
- else {
98
- console.log('⚠️ Message not received (might still be processing)\n');
99
- }
100
- // 8. Test deleteQueues
101
- console.log('8. Testing deleteQueues...');
102
- await rabbitmq_with_retry_and_dlq_1.publisher.deleteQueues('test_queue');
103
- console.log('✓ Test queue deleted\n');
104
- console.log('='.repeat(60));
105
- console.log('✅ ALL TESTS PASSED!');
106
- console.log('='.repeat(60));
107
- }
108
- catch (error) {
109
- console.error('\n❌ TEST FAILED:');
110
- console.error(error);
111
- process.exit(1);
112
- }
113
- finally {
114
- // Cleanup
115
- console.log('\nCleaning up...');
116
- try {
117
- await (0, rabbitmq_with_retry_and_dlq_1.closeRabbitMQ)();
118
- console.log('✓ Connections closed');
119
- }
120
- catch (error) {
121
- console.error('Error during cleanup:', error);
122
- }
123
- process.exit(0);
124
- }
125
- }
126
- // Run test
127
- testConnection().catch((error) => {
128
- console.error('Fatal error:', error);
129
- process.exit(1);
130
- });
131
- //# sourceMappingURL=test-package.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"test-package.js","sourceRoot":"","sources":["../test-package.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;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