rascal 17.0.0 → 17.0.2
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/CHANGELOG.md +46 -35
- package/README.md +6 -6
- package/examples/busy-publisher/config.json +0 -5
- package/lib/amqp/SubscriberError.js +52 -28
- package/lib/amqp/Vhost.js +11 -12
- package/lib/amqp/tasks/createConnection.js +1 -1
- package/lib/config/configure.js +1 -1
- package/lib/utils/setTimeoutUnref.js +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 17.0.2
|
|
4
|
+
|
|
5
|
+
- Update guidesmiths references to onebeyond.
|
|
6
|
+
- Dedupe channel poole ready check
|
|
7
|
+
- Remove unnecessary subscription config from busy publisher example
|
|
8
|
+
- Fixed bug where hostname connection order was not properly randomised
|
|
9
|
+
|
|
10
|
+
## 17.0.1
|
|
11
|
+
|
|
12
|
+
- Rework the republish and forward recovery strategies to remove remote chance of repeat ack/nack
|
|
13
|
+
|
|
3
14
|
## 17.0.0
|
|
4
15
|
|
|
5
|
-
- Updated the configuration processing as per https://github.com/
|
|
16
|
+
- Updated the configuration processing as per https://github.com/onebeyond/rascal/issues/219
|
|
6
17
|
- Test on Node 20
|
|
7
18
|
- Abandon dependabot (too noisy)
|
|
8
19
|
- Bump deps
|
|
9
|
-
- Add support for channel level prefetch as per https://github.com/
|
|
20
|
+
- Add support for channel level prefetch as per https://github.com/onebeyond/rascal/issues/221
|
|
10
21
|
- Dropped prettier (it does nothing of the sort!)
|
|
11
22
|
|
|
12
23
|
## 16.3.0
|
|
@@ -41,7 +52,7 @@
|
|
|
41
52
|
|
|
42
53
|
## 15.0.1
|
|
43
54
|
|
|
44
|
-
- Fix MaxListenersExceeded warning when there are more than 10 vhosts - See https://github.com/
|
|
55
|
+
- Fix MaxListenersExceeded warning when there are more than 10 vhosts - See https://github.com/onebeyond/rascal/issues/206
|
|
45
56
|
|
|
46
57
|
## 15.0.0
|
|
47
58
|
|
|
@@ -50,11 +61,11 @@
|
|
|
50
61
|
|
|
51
62
|
## 14.4.5
|
|
52
63
|
|
|
53
|
-
- Fixed issue where a partial password could be logged in debug - See https://github.com/
|
|
64
|
+
- Fixed issue where a partial password could be logged in debug - See https://github.com/onebeyond/rascal/issues/200 - thanks @matt1097
|
|
54
65
|
|
|
55
66
|
## 14.4.4
|
|
56
67
|
|
|
57
|
-
- Fixed issue where channels were not returned to the pool after publishing a large messag - See https://github.com/
|
|
68
|
+
- Fixed issue where channels were not returned to the pool after publishing a large messag - See https://github.com/onebeyond/rascal/issues/199
|
|
58
69
|
|
|
59
70
|
## 14.4.3
|
|
60
71
|
|
|
@@ -77,15 +88,15 @@
|
|
|
77
88
|
## 14.4.1
|
|
78
89
|
|
|
79
90
|
- Bump dependencies / fix audit warnings
|
|
80
|
-
- Fix busy publisher example to consistenly use regular channels - See https://github.com/
|
|
91
|
+
- Fix busy publisher example to consistenly use regular channels - See https://github.com/onebeyond/rascal/issues/194
|
|
81
92
|
|
|
82
93
|
## 14.4.0
|
|
83
94
|
|
|
84
|
-
- Report validation error when no vhosts are specified - See https://github.com/
|
|
95
|
+
- Report validation error when no vhosts are specified - See https://github.com/onebeyond/rascal/issues/181
|
|
85
96
|
|
|
86
97
|
## 14.3.0
|
|
87
98
|
|
|
88
|
-
- Clone config instead of freezing it so buffers will work - See https://github.com/
|
|
99
|
+
- Clone config instead of freezing it so buffers will work - See https://github.com/onebeyond/rascal/issues/92
|
|
89
100
|
|
|
90
101
|
## 14.2.1
|
|
91
102
|
|
|
@@ -93,15 +104,15 @@
|
|
|
93
104
|
|
|
94
105
|
## 14.2.0
|
|
95
106
|
|
|
96
|
-
- Add json schema (lib/config/schema.json) - See https://github.com/
|
|
107
|
+
- Add json schema (lib/config/schema.json) - See https://github.com/onebeyond/rascal/issues/168
|
|
97
108
|
|
|
98
109
|
## 14.1.0
|
|
99
110
|
|
|
100
|
-
- Adds support for custom user agents - See https://github.com/
|
|
111
|
+
- Adds support for custom user agents - See https://github.com/onebeyond/rascal/issues/170
|
|
101
112
|
|
|
102
113
|
## 14.0.1
|
|
103
114
|
|
|
104
|
-
- Fixes https://github.com/
|
|
115
|
+
- Fixes https://github.com/onebeyond/rascal/issues/178
|
|
105
116
|
|
|
106
117
|
## 14.0.0
|
|
107
118
|
|
|
@@ -122,15 +133,15 @@
|
|
|
122
133
|
|
|
123
134
|
## 13.1.2
|
|
124
135
|
|
|
125
|
-
- Fixed various issues when queue names contained period characters. Reported in https://github.com/
|
|
136
|
+
- Fixed various issues when queue names contained period characters. Reported in https://github.com/onebeyond/rascal/issues/166
|
|
126
137
|
|
|
127
138
|
## 13.1.1
|
|
128
139
|
|
|
129
|
-
- Moved setMaxListeners to createConnection task to suppress misleading 'Possible EventEmitter memory leak detected' warning. See https://github.com/
|
|
140
|
+
- Moved setMaxListeners to createConnection task to suppress misleading 'Possible EventEmitter memory leak detected' warning. See https://github.com/onebeyond/rascal/issues/164 for more details.
|
|
130
141
|
|
|
131
142
|
## 13.1.0
|
|
132
143
|
|
|
133
|
-
- Fixed bug where Rascal could wait indefinitely for channels to be destroyed if shutdown was called following a heartbeat timeout. See https://github.com/
|
|
144
|
+
- Fixed bug where Rascal could wait indefinitely for channels to be destroyed if shutdown was called following a heartbeat timeout. See https://github.com/onebeyond/rascal/issues/158 for more details.
|
|
134
145
|
|
|
135
146
|
## 13.0.6
|
|
136
147
|
|
|
@@ -143,7 +154,7 @@
|
|
|
143
154
|
|
|
144
155
|
## 13.0.4
|
|
145
156
|
|
|
146
|
-
- Fixed https://github.com/
|
|
157
|
+
- Fixed https://github.com/onebeyond/rascal/issues/156
|
|
147
158
|
|
|
148
159
|
## 13.0.3
|
|
149
160
|
|
|
@@ -151,7 +162,7 @@
|
|
|
151
162
|
|
|
152
163
|
## 13.0.2
|
|
153
164
|
|
|
154
|
-
- Fixed https://github.com/
|
|
165
|
+
- Fixed https://github.com/onebeyond/rascal/issues/150
|
|
155
166
|
|
|
156
167
|
## 13.0.1
|
|
157
168
|
|
|
@@ -171,7 +182,7 @@
|
|
|
171
182
|
|
|
172
183
|
## 12.0.3
|
|
173
184
|
|
|
174
|
-
- Fix https://github.com/
|
|
185
|
+
- Fix https://github.com/onebeyond/rascal/issues/141
|
|
175
186
|
- Fix error message typos
|
|
176
187
|
- Bump lodash
|
|
177
188
|
|
|
@@ -182,7 +193,7 @@
|
|
|
182
193
|
## 12.0.1
|
|
183
194
|
|
|
184
195
|
- Moved from travis to github actions
|
|
185
|
-
- Fix broker waiting indefinitely when shutdown is called after losing a connection. See [#126](https://github.com/
|
|
196
|
+
- Fix broker waiting indefinitely when shutdown is called after losing a connection. See [#126](https://github.com/onebeyond/rascal/issues/126)
|
|
186
197
|
|
|
187
198
|
## 12.0.0
|
|
188
199
|
|
|
@@ -210,29 +221,29 @@
|
|
|
210
221
|
|
|
211
222
|
### Updated
|
|
212
223
|
|
|
213
|
-
- Improved readme as per issue [#111](https://github.com/
|
|
224
|
+
- Improved readme as per issue [#111](https://github.com/onebeyond/rascal/issues/111)
|
|
214
225
|
|
|
215
226
|
### Fixed
|
|
216
227
|
|
|
217
|
-
- Fixed issue [#123](https://github.com/
|
|
228
|
+
- Fixed issue [#123](https://github.com/onebeyond/rascal/issues/123), where a race condition was causing channels to be closed twice. Thanks @cinnq346.
|
|
218
229
|
|
|
219
230
|
## 10.2.4
|
|
220
231
|
|
|
221
232
|
### Fixed
|
|
222
233
|
|
|
223
|
-
- Fixed issue [#122](https://github.com/
|
|
234
|
+
- Fixed issue [#122](https://github.com/onebeyond/rascal/issues/122), where error listeners were registered once, so repeated errors could bubble up and crash node
|
|
224
235
|
|
|
225
236
|
## 10.2.3
|
|
226
237
|
|
|
227
238
|
### Fixed
|
|
228
239
|
|
|
229
|
-
- Fixed second part of issue [#121](https://github.com/
|
|
240
|
+
- Fixed second part of issue [#121](https://github.com/onebeyond/rascal/issues/121), where the generic-pool could cause tight loops and memory leaks
|
|
230
241
|
|
|
231
242
|
## 10.2.2
|
|
232
243
|
|
|
233
244
|
### Fixed
|
|
234
245
|
|
|
235
|
-
- Fixed issue [#121](https://github.com/
|
|
246
|
+
- Fixed issue [#121](https://github.com/onebeyond/rascal/issues/121), which caused rascals connection index to permanently increment rather than cycling back to 0. Consequently if all nodes in a cluster failed, Rascal could crash the application.
|
|
236
247
|
|
|
237
248
|
## 10.2.1
|
|
238
249
|
|
|
@@ -261,7 +272,7 @@
|
|
|
261
272
|
|
|
262
273
|
### Updated
|
|
263
274
|
|
|
264
|
-
- Set vhost max event listeners to inifinity (see https://github.com/
|
|
275
|
+
- Set vhost max event listeners to inifinity (see https://github.com/onebeyond/rascal/issues/99)
|
|
265
276
|
|
|
266
277
|
## 10.0.0
|
|
267
278
|
|
|
@@ -285,13 +296,13 @@
|
|
|
285
296
|
|
|
286
297
|
### Updated
|
|
287
298
|
|
|
288
|
-
- [Fixed #78](https://github.com/
|
|
299
|
+
- [Fixed #78](https://github.com/onebeyond/rascal/issues/78) by using a baseline config, and only laying connection options via withDefaultConfig
|
|
289
300
|
|
|
290
301
|
## 9.2.0
|
|
291
302
|
|
|
292
303
|
### Added
|
|
293
304
|
|
|
294
|
-
- [Fixed #93](https://github.com/
|
|
305
|
+
- [Fixed #93](https://github.com/onebeyond/rascal/issues/93) through use of setInterval to keep node process active in the event of broker restart.
|
|
295
306
|
|
|
296
307
|
### Updated
|
|
297
308
|
|
|
@@ -343,8 +354,8 @@
|
|
|
343
354
|
|
|
344
355
|
### Updated
|
|
345
356
|
|
|
346
|
-
- Fixed [#86](https://github.com/
|
|
347
|
-
- Fixed [#84](https://github.com/
|
|
357
|
+
- Fixed [#86](https://github.com/onebeyond/rascal/issues/85)
|
|
358
|
+
- Fixed [#84](https://github.com/onebeyond/rascal/issues/84). Thanks @huikaihoo
|
|
348
359
|
|
|
349
360
|
### Added
|
|
350
361
|
|
|
@@ -354,14 +365,14 @@
|
|
|
354
365
|
|
|
355
366
|
### Updated
|
|
356
367
|
|
|
357
|
-
- emit error when publishFn err Channel closed as oer https://github.com/
|
|
368
|
+
- emit error when publishFn err Channel closed as oer https://github.com/onebeyond/rascal/pull/81. Thanks @zijin-m
|
|
358
369
|
|
|
359
370
|
## 8.0.0
|
|
360
371
|
|
|
361
372
|
### Updated
|
|
362
373
|
|
|
363
374
|
- Drop support for Node 6
|
|
364
|
-
- Updated dependencies as per https://github.com/
|
|
375
|
+
- Updated dependencies as per https://github.com/onebeyond/rascal/pull/75. Thanks @ravihara
|
|
365
376
|
|
|
366
377
|
## 7.0.0
|
|
367
378
|
|
|
@@ -374,7 +385,7 @@
|
|
|
374
385
|
|
|
375
386
|
### Fixed
|
|
376
387
|
|
|
377
|
-
- Fixed [#72](https://github.com/
|
|
388
|
+
- Fixed [#72](https://github.com/onebeyond/rascal/issues/72) which meant published messages waiting for a channel would be lost on connection error
|
|
378
389
|
|
|
379
390
|
## 6.0.2
|
|
380
391
|
|
|
@@ -388,7 +399,7 @@
|
|
|
388
399
|
|
|
389
400
|
## 6.0.0
|
|
390
401
|
|
|
391
|
-
- Improved channel pool management (includes a breaking config change - see https://github.com/
|
|
402
|
+
- Improved channel pool management (includes a breaking config change - see https://github.com/onebeyond/rascal#channel-pooling).
|
|
392
403
|
|
|
393
404
|
## 5.1.0
|
|
394
405
|
|
|
@@ -581,7 +592,7 @@
|
|
|
581
592
|
### Updated
|
|
582
593
|
|
|
583
594
|
- Using lodash defaultsDeep instead of merge-defaults (fixes hoek vulnerability). The behaviour seems consistent but releasing as a breaking change as a precaution.
|
|
584
|
-
- Unqualified default publications and subscriptions are no longer supported. See https://github.com/
|
|
595
|
+
- Unqualified default publications and subscriptions are no longer supported. See https://github.com/onebeyond/rascal/issues/20
|
|
585
596
|
- Testing on node 10
|
|
586
597
|
|
|
587
598
|
## 2.12.2
|
|
@@ -722,7 +733,7 @@
|
|
|
722
733
|
|
|
723
734
|
### Fixed
|
|
724
735
|
|
|
725
|
-
- confirmPoolSize option as per https://github.com/
|
|
736
|
+
- confirmPoolSize option as per https://github.com/onebeyond/rascal/pull/19
|
|
726
737
|
|
|
727
738
|
## 1.4.0
|
|
728
739
|
|
|
@@ -751,7 +762,7 @@
|
|
|
751
762
|
|
|
752
763
|
### Added
|
|
753
764
|
|
|
754
|
-
- Workaround for https://github.com/
|
|
765
|
+
- Workaround for https://github.com/onebeyond/rascal/issues/17
|
|
755
766
|
|
|
756
767
|
## 1.1.0
|
|
757
768
|
|
package/README.md
CHANGED
|
@@ -4,9 +4,9 @@ Rascal is a rich pub/sub wrapper around [amqplib](https://www.npmjs.com/package/
|
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/rascal)
|
|
6
6
|
[](https://www.npmjs.com/package/rascal)
|
|
7
|
-
[](https://github.com/onebeyond/rascal/actions?query=workflow%3A%22Node.js+CI%22)
|
|
8
|
+
[](https://codeclimate.com/github/onebeyond/rascal)
|
|
9
|
+
[](https://codeclimate.com/github/onebeyond/rascal/coverage)
|
|
10
10
|
[](https://snyk.io/advisor/npm-package/rascal)
|
|
11
11
|
[](https://www.npmjs.com/package/zunit)
|
|
12
12
|
|
|
@@ -53,7 +53,7 @@ Rascal@14 waits for inflight messages to be acknowledged before closing subscrib
|
|
|
53
53
|
|
|
54
54
|
### Special Note
|
|
55
55
|
|
|
56
|
-
RabbitMQ 3.8.0 introduced [quorum queues](https://www.rabbitmq.com/quorum-queues.html). Although quorum queues may not be suitable in all situations, they provide [poison message handling](https://www.rabbitmq.com/quorum-queues.html#poison-message-handling) without the need for an external [redelivery counter](https://github.com/
|
|
56
|
+
RabbitMQ 3.8.0 introduced [quorum queues](https://www.rabbitmq.com/quorum-queues.html). Although quorum queues may not be suitable in all situations, they provide [poison message handling](https://www.rabbitmq.com/quorum-queues.html#poison-message-handling) without the need for an external [redelivery counter](https://github.com/onebeyond/rascal#dealing-with-redeliveries) and offer better data safety in the event of a network partition. You can read more about them [here](https://www.cloudamqp.com/blog/reasons-you-should-switch-to-quorum-queues.html) and [here](https://blog.rabbitmq.com/posts/2020/06/quorum-queues-local-delivery).
|
|
57
57
|
|
|
58
58
|
## Examples
|
|
59
59
|
|
|
@@ -116,7 +116,7 @@ Broker.create(config, (err, broker) => {
|
|
|
116
116
|
});
|
|
117
117
|
```
|
|
118
118
|
|
|
119
|
-
See [here](https://github.com/
|
|
119
|
+
See [here](https://github.com/onebeyond/rascal/tree/master/examples) for more examples.
|
|
120
120
|
|
|
121
121
|
## Avoiding Potential Message Loss
|
|
122
122
|
|
|
@@ -1401,7 +1401,7 @@ Rascal provides three counter implementations:
|
|
|
1401
1401
|
2. inMemory - useful only for testing since if your node process crashes, the counter will be vaporised too
|
|
1402
1402
|
3. inMemoryCluster - like the inMemory, but since the counter resides in the master it survives worker crashes.
|
|
1403
1403
|
|
|
1404
|
-
Of the three only inMemoryCluster is useful in production, and then only if you are using [clustering](https://nodejs.org/api/cluster.html). See the [advanced example](https://github.com/
|
|
1404
|
+
Of the three only inMemoryCluster is useful in production, and then only if you are using [clustering](https://nodejs.org/api/cluster.html). See the [advanced example](https://github.com/onebeyond/rascal/tree/master/examples/advanced) for how to configure it.
|
|
1405
1405
|
|
|
1406
1406
|
#### Implementing your own counter
|
|
1407
1407
|
|
|
@@ -68,13 +68,12 @@ module.exports = function SubscriptionRecovery(broker, vhost) {
|
|
|
68
68
|
execute(session, message, err, strategyConfig, next) {
|
|
69
69
|
debug('Republishing message: %s', message.properties.messageId);
|
|
70
70
|
|
|
71
|
-
const once = _.once(next);
|
|
72
71
|
const originalQueue = _.get(message, 'properties.headers.rascal.originalQueue');
|
|
73
72
|
const republished = _.get(message, ['properties', 'headers', 'rascal', 'recovery', originalQueue, 'republished'], 0);
|
|
74
73
|
|
|
75
74
|
if (strategyConfig.attempts && strategyConfig.attempts <= republished) {
|
|
76
75
|
debug('Skipping recovery - message: %s has already been republished %d times.', message.properties.messageId, republished);
|
|
77
|
-
return
|
|
76
|
+
return next(null, false);
|
|
78
77
|
}
|
|
79
78
|
|
|
80
79
|
const publishOptions = _.cloneDeep(message.properties);
|
|
@@ -87,33 +86,50 @@ module.exports = function SubscriptionRecovery(broker, vhost) {
|
|
|
87
86
|
|
|
88
87
|
if (strategyConfig.immediateNack) _.set(publishOptions, ['headers', 'rascal', 'recovery', originalQueue, 'immediateNack'], true);
|
|
89
88
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
});
|
|
96
|
-
};
|
|
89
|
+
const ackMessage = () => {
|
|
90
|
+
session._ack(message, (err) => {
|
|
91
|
+
next(err, true);
|
|
92
|
+
});
|
|
93
|
+
};
|
|
97
94
|
|
|
98
|
-
|
|
95
|
+
const nackMessage = (err) => {
|
|
96
|
+
session._nack(message, (_nackErr) => {
|
|
97
|
+
// nackError just means the channel was already closed meaning the original message would have been rolled back
|
|
98
|
+
next(err);
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const ackOrNack = _.once((err) => {
|
|
103
|
+
return err ? nackMessage(err) : ackMessage();
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
vhost.getConfirmChannel((err, publisherChannel) => {
|
|
107
|
+
if (err) return ackOrNack(err);
|
|
99
108
|
|
|
100
|
-
if (!publisherChannel) return
|
|
109
|
+
if (!publisherChannel) return ackOrNack(new Error('Unable to handle subscriber error by republishing. The VHost is shutting down'));
|
|
101
110
|
|
|
102
111
|
publisherChannel.on('error', (err) => {
|
|
103
|
-
|
|
112
|
+
ackOrNack(err);
|
|
104
113
|
});
|
|
114
|
+
|
|
105
115
|
publisherChannel.on('return', () => {
|
|
106
|
-
|
|
116
|
+
ackOrNack(new Error(format('Message: %s was republished to queue: %s, but was returned', message.properties.messageId, originalQueue)));
|
|
107
117
|
});
|
|
108
118
|
|
|
109
119
|
publisherChannel.publish(undefined, originalQueue, message.content, publishOptions, (err) => {
|
|
110
|
-
if (err)
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
120
|
+
if (err) {
|
|
121
|
+
// Channel will already be closed, reclosing will trigger an error
|
|
122
|
+
publisherChannel.removeAllListeners();
|
|
123
|
+
|
|
124
|
+
debug('Message: %s failed to be republished to queue: %s %d times - %s', message.properties.messageId, originalQueue, republished + 1, err.message);
|
|
125
|
+
ackOrNack(err);
|
|
126
|
+
} else {
|
|
127
|
+
publisherChannel.close();
|
|
128
|
+
publisherChannel.removeAllListeners();
|
|
129
|
+
|
|
130
|
+
debug('Message: %s was republished to queue: %s %d times', message.properties.messageId, originalQueue, republished + 1);
|
|
131
|
+
ackOrNack();
|
|
132
|
+
}
|
|
117
133
|
});
|
|
118
134
|
});
|
|
119
135
|
},
|
|
@@ -123,13 +139,12 @@ module.exports = function SubscriptionRecovery(broker, vhost) {
|
|
|
123
139
|
execute(session, message, err, strategyConfig, next) {
|
|
124
140
|
debug('Forwarding message: %s to publication: %s', message.properties.messageId, strategyConfig.publication);
|
|
125
141
|
|
|
126
|
-
const once = _.once(next);
|
|
127
142
|
const originalQueue = _.get(message, 'properties.headers.rascal.originalQueue');
|
|
128
143
|
const forwarded = _.get(message, ['properties', 'headers', 'rascal', 'recovery', originalQueue, 'forwarded'], 0);
|
|
129
144
|
|
|
130
145
|
if (strategyConfig.attempts && strategyConfig.attempts <= forwarded) {
|
|
131
146
|
debug('Skipping recovery - message: %s has already been forwarded %d times.', message.properties.messageId, forwarded);
|
|
132
|
-
return
|
|
147
|
+
return next(null, false);
|
|
133
148
|
}
|
|
134
149
|
|
|
135
150
|
// See https://github.com/rabbitmq/rabbitmq-server/issues/161
|
|
@@ -141,30 +156,39 @@ module.exports = function SubscriptionRecovery(broker, vhost) {
|
|
|
141
156
|
_.set(forwardOverrides, 'options.headers.rascal.error.message', _.truncate(err.message, { length: 1024 }));
|
|
142
157
|
_.set(forwardOverrides, 'options.headers.rascal.error.code', err.code);
|
|
143
158
|
|
|
159
|
+
const ackMessage = () => {
|
|
160
|
+
session._ack(message, (err) => {
|
|
161
|
+
next(err, true);
|
|
162
|
+
});
|
|
163
|
+
};
|
|
164
|
+
|
|
144
165
|
const nackMessage = (err) => {
|
|
145
166
|
session._nack(message, (_nackErr) => {
|
|
146
167
|
// nackError just means the channel was already closed meaning the original message would have been rolled back
|
|
147
|
-
|
|
168
|
+
next(err);
|
|
148
169
|
});
|
|
149
170
|
};
|
|
150
171
|
|
|
172
|
+
const ackOrNack = _.once((err) => {
|
|
173
|
+
return err ? nackMessage(err) : ackMessage();
|
|
174
|
+
});
|
|
175
|
+
|
|
151
176
|
broker.forward(strategyConfig.publication, message, forwardOverrides, (err, publication) => {
|
|
152
177
|
if (err) return nackMessage(err);
|
|
153
178
|
|
|
154
179
|
publication.on('success', () => {
|
|
155
180
|
debug('Message: %s was forwarded to publication: %s %d times', message.properties.messageId, strategyConfig.publication, forwarded + 1);
|
|
156
|
-
|
|
157
|
-
once(ackErr, true);
|
|
158
|
-
});
|
|
181
|
+
ackOrNack();
|
|
159
182
|
});
|
|
160
183
|
|
|
161
184
|
publication.on('error', (err) => {
|
|
162
|
-
|
|
185
|
+
debug('Message: %s failed to be forwarded to publication: %s %d times - %s', message.properties.messageId, strategyConfig.publication, forwarded + 1, err.message);
|
|
186
|
+
ackOrNack(err);
|
|
163
187
|
});
|
|
164
188
|
|
|
165
189
|
publication.on('return', () => {
|
|
166
190
|
publication.removeAllListeners('success');
|
|
167
|
-
|
|
191
|
+
ackOrNack(new Error(format('Message: %s was forwarded to publication: %s, but was returned', message.properties.messageId, strategyConfig.publication)));
|
|
168
192
|
});
|
|
169
193
|
});
|
|
170
194
|
},
|
package/lib/amqp/Vhost.js
CHANGED
|
@@ -201,7 +201,8 @@ function Vhost(vhostConfig, components) {
|
|
|
201
201
|
createChannelWhenInitialised(options.confirm, (err, channel) => {
|
|
202
202
|
if (err) return deferRejection(reject, err);
|
|
203
203
|
if (!channel) return deferRejection(reject, new Error('Vhost is shutting down'));
|
|
204
|
-
const destroyChannel = _.once(() => {
|
|
204
|
+
const destroyChannel = _.once((err) => {
|
|
205
|
+
console.log('Destroying channel', err);
|
|
205
206
|
debug('Destroying %s channel: %s for vhost: %s due to error or close event', mode, channel._rascal_id, vhostConfig.name);
|
|
206
207
|
channel._rascal_closed = true;
|
|
207
208
|
if (pool.isBorrowedResource(channel)) {
|
|
@@ -289,11 +290,7 @@ function Vhost(vhostConfig, components) {
|
|
|
289
290
|
.catch((err) => {
|
|
290
291
|
debug('Error releasing %s channel: %s. %s', mode, channel._rascal_id, err.message);
|
|
291
292
|
})
|
|
292
|
-
.then(() =>
|
|
293
|
-
if (poolQueue.length() > 0 || !busy) return;
|
|
294
|
-
busy = false;
|
|
295
|
-
self.emit('ready', stats());
|
|
296
|
-
});
|
|
293
|
+
.then(() => checkReady());
|
|
297
294
|
}
|
|
298
295
|
|
|
299
296
|
function destroy(channel) {
|
|
@@ -303,11 +300,13 @@ function Vhost(vhostConfig, components) {
|
|
|
303
300
|
.catch((err) => {
|
|
304
301
|
debug('Error destroying %s channel: %s. %s', mode, channel._rascal_id, err.message);
|
|
305
302
|
})
|
|
306
|
-
.then(() =>
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
303
|
+
.then(() => checkReady());
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
function checkReady() {
|
|
307
|
+
if (poolQueue.length() > 0 || !busy) return;
|
|
308
|
+
busy = false;
|
|
309
|
+
self.emit('ready', stats());
|
|
311
310
|
}
|
|
312
311
|
|
|
313
312
|
function drain(next) {
|
|
@@ -376,7 +375,7 @@ function Vhost(vhostConfig, components) {
|
|
|
376
375
|
}
|
|
377
376
|
if (!connection) return next(new Error(format('Vhost: %s must be initialised before you can create a channel', self.name)));
|
|
378
377
|
|
|
379
|
-
// Same problem as https://github.com/
|
|
378
|
+
// Same problem as https://github.com/onebeyond/rascal/issues/17
|
|
380
379
|
const once = _.once(next);
|
|
381
380
|
let invocations = 0;
|
|
382
381
|
const channelId = uuid();
|
|
@@ -31,7 +31,7 @@ module.exports = _.curry((config, ctx, next) => {
|
|
|
31
31
|
function connect(connectionConfig, cb) {
|
|
32
32
|
debug('Connecting to broker using url: %s', connectionConfig.loggableUrl);
|
|
33
33
|
|
|
34
|
-
// See https://github.com/
|
|
34
|
+
// See https://github.com/onebeyond/rascal/issues/17
|
|
35
35
|
const once = _.once(cb);
|
|
36
36
|
let invocations = 0;
|
|
37
37
|
|
package/lib/config/configure.js
CHANGED
|
@@ -132,7 +132,7 @@ module.exports = _.curry((rascalConfig, next) => {
|
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
function setConnectionIndex(connection, strategy, index) {
|
|
135
|
-
connection.index = strategy === 'fixed' ? index : getConnectionIndex(strategy, `${connection.
|
|
135
|
+
connection.index = strategy === 'fixed' ? index : getConnectionIndex(strategy, `${connection.hostname}:${connection.port}`);
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
function getConnectionIndex(strategy, hostname) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rascal",
|
|
3
|
-
"version": "17.0.
|
|
3
|
+
"version": "17.0.2",
|
|
4
4
|
"description": "A config driven wrapper for amqplib supporting multi-host connections, automatic error recovery, redelivery flood protection, transparent encryption / decryption, channel pooling and publication timeouts",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"dependencies": {
|
|
@@ -59,12 +59,12 @@
|
|
|
59
59
|
],
|
|
60
60
|
"repository": {
|
|
61
61
|
"type": "git",
|
|
62
|
-
"url": "https://github.com/
|
|
62
|
+
"url": "https://github.com/onebeyond/rascal.git"
|
|
63
63
|
},
|
|
64
64
|
"bugs": {
|
|
65
|
-
"url": "https://github.com/
|
|
65
|
+
"url": "https://github.com/onebeyond/rascal/issues"
|
|
66
66
|
},
|
|
67
|
-
"homepage": "https://
|
|
67
|
+
"homepage": "https://onebeyond.github.io/rascal/",
|
|
68
68
|
"author": "Stephen Cresswell",
|
|
69
69
|
"license": "MIT",
|
|
70
70
|
"zUnit": {
|