@droidsolutions-oss/amqp-ts 3.0.4 → 4.0.0-develop.1
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 +186 -45
- package/lib/AmqpProperties.js +1 -2
- package/lib/Binding.d.ts +36 -6
- package/lib/Binding.js +244 -75
- package/lib/Binding.js.map +1 -1
- package/lib/Connection/Connection.d.ts +87 -46
- package/lib/Connection/Connection.js +360 -181
- package/lib/Connection/Connection.js.map +1 -1
- package/lib/Connection/ConnectionMetrics.js +1 -2
- package/lib/Connection/RecoveryOptions.d.ts +6 -0
- package/lib/Connection/RecoveryOptions.js +2 -0
- package/lib/Connection/RecoveryOptions.js.map +1 -0
- package/lib/Connection/Topology.d.ts +1 -1
- package/lib/Connection/Topology.js +1 -2
- package/lib/Deferred.d.ts +18 -0
- package/lib/Deferred.js +33 -0
- package/lib/Deferred.js.map +1 -0
- package/lib/Exchange/DeclarationOptions.js +1 -2
- package/lib/Exchange/Exchange.d.ts +38 -17
- package/lib/Exchange/Exchange.js +204 -159
- package/lib/Exchange/Exchange.js.map +1 -1
- package/lib/Exchange/ExchangeType.js +1 -2
- package/lib/Exchange/InitializeResult.js +1 -2
- package/lib/LoggerFactory.js +1 -5
- package/lib/LoggerFactory.js.map +1 -1
- package/lib/Message.d.ts +11 -10
- package/lib/Message.js +66 -37
- package/lib/Message.js.map +1 -1
- package/lib/Queue/DeclarationOptions.js +1 -2
- package/lib/Queue/DeleteResult.js +1 -2
- package/lib/Queue/InitializeResult.js +1 -2
- package/lib/Queue/Queue.d.ts +87 -26
- package/lib/Queue/Queue.js +440 -207
- package/lib/Queue/Queue.js.map +1 -1
- package/lib/Queue/StartConsumerResult.js +1 -2
- package/lib/amqp-ts.d.ts +0 -1
- package/lib/amqp-ts.js +2 -7
- package/lib/amqp-ts.js.map +1 -1
- package/lib/errorMessage.d.ts +1 -0
- package/lib/errorMessage.js +18 -0
- package/lib/errorMessage.js.map +1 -0
- package/lib/index.d.ts +19 -14
- package/lib/index.js +7 -13
- package/lib/index.js.map +1 -1
- package/package.json +38 -60
- package/lib/Connection/ReconnectStrategy.d.ts +0 -4
- package/lib/Connection/ReconnectStrategy.js +0 -3
- package/lib/Connection/ReconnectStrategy.js.map +0 -1
package/lib/Message.js
CHANGED
|
@@ -1,11 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
2
|
+
import { IllegalOperationError } from "amqplib";
|
|
3
|
+
import { errorMessage } from "./errorMessage.js";
|
|
4
|
+
import { Queue } from "./Queue/Queue.js";
|
|
5
5
|
/**
|
|
6
6
|
* Represents a message that can be send via AMQP.
|
|
7
7
|
*/
|
|
8
|
-
class Message {
|
|
8
|
+
export class Message {
|
|
9
|
+
fields;
|
|
10
|
+
/**
|
|
11
|
+
* for received messages only: the channel it has been received on
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
_channel;
|
|
15
|
+
/**
|
|
16
|
+
* received messages only: original amqplib message
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
_message;
|
|
20
|
+
/** Additional AQMP properties of the message. */
|
|
21
|
+
properties;
|
|
22
|
+
/** The original contant of the message. */
|
|
23
|
+
content;
|
|
9
24
|
/**
|
|
10
25
|
* Initializes a new instance of the @see Message class.
|
|
11
26
|
*
|
|
@@ -38,58 +53,73 @@ class Message {
|
|
|
38
53
|
* @throws {Error} If the content type in the message properties is not set to application/json.
|
|
39
54
|
*/
|
|
40
55
|
getJsonContent() {
|
|
41
|
-
var _a;
|
|
42
56
|
if (this.properties.contentType !== "application/json") {
|
|
43
57
|
throw new Error("The content of the message is not set as application/json.");
|
|
44
58
|
}
|
|
45
|
-
return JSON.parse(this.content.toString(
|
|
59
|
+
return JSON.parse(this.content.toString(this.properties.contentEncoding ?? "utf-8"));
|
|
46
60
|
}
|
|
47
61
|
/**
|
|
48
|
-
*
|
|
49
|
-
* @see content of the message.
|
|
62
|
+
* Publishes the message on the destination's channel once the destination is initialized. Appends the current
|
|
63
|
+
* @see properties object and the @see content of the message.
|
|
64
|
+
*
|
|
65
|
+
* If the channel turns out to be closed or closing (the connection or the channel was lost, or amqplib is closing
|
|
66
|
+
* the connection after a protocol error), the message is published again once the destination is initialized
|
|
67
|
+
* again. A message that can never be published (the destination failed or was closed or deleted, recovery gave up
|
|
68
|
+
* or the connection was closed) is logged at warn level and dropped.
|
|
50
69
|
*
|
|
51
70
|
* @param destination The destination of the message.
|
|
52
71
|
* @param routingKey An optional routing key.
|
|
53
72
|
*/
|
|
54
73
|
sendTo(destination, routingKey = "") {
|
|
55
74
|
let exchange;
|
|
56
|
-
|
|
57
|
-
|
|
75
|
+
if (destination instanceof Queue) {
|
|
76
|
+
exchange = "";
|
|
77
|
+
routingKey = destination.name;
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
exchange = destination.name;
|
|
81
|
+
}
|
|
82
|
+
void this._publish(destination, exchange, routingKey);
|
|
83
|
+
}
|
|
84
|
+
async _publish(destination, exchange, routingKey) {
|
|
85
|
+
const connection = destination.connection;
|
|
86
|
+
const log = () => connection.loggerFactory(this.constructor);
|
|
87
|
+
for (;;) {
|
|
88
|
+
const ready = destination.initialized;
|
|
89
|
+
try {
|
|
90
|
+
await ready;
|
|
91
|
+
}
|
|
92
|
+
catch (err) {
|
|
93
|
+
const reason = errorMessage(err);
|
|
94
|
+
log().warn({ err }, "Dropping message to '%s', it cannot be initialized: %s", destination.name, reason);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
58
97
|
try {
|
|
59
98
|
if (!this.properties.timestamp) {
|
|
60
99
|
// Set timestamp if not set by user
|
|
61
100
|
this.properties.timestamp = Math.floor(new Date().getTime() / 1000);
|
|
62
101
|
}
|
|
63
102
|
destination._channel.publish(exchange, routingKey, this.content, this.properties);
|
|
64
|
-
|
|
103
|
+
connection._increaseCounter("sentMessages");
|
|
104
|
+
return;
|
|
65
105
|
}
|
|
66
106
|
catch (err) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
});
|
|
107
|
+
if (!(err instanceof IllegalOperationError)) {
|
|
108
|
+
const reason = err.message;
|
|
109
|
+
log().error({ err }, "Publishing to '%s' failed, dropping the message: %s", destination.name, reason);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (destination._isClosedOnPurpose) {
|
|
113
|
+
// close() or delete() of the destination or the connection: nothing re-initializes it
|
|
114
|
+
log().warn({ err }, "Dropping message to '%s', its channel is closed.", destination.name);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
// the channel or the connection is closed or closing otherwise (amqplib closes the connection itself on a
|
|
118
|
+
// protocol error, and publishing throws before the close arrives); once it is closed initialized is replaced
|
|
119
|
+
log().debug({ err }, "Channel of '%s' closed, publishing again once it is re-initialized.", destination.name);
|
|
120
|
+
await destination._initializedChanged(ready);
|
|
83
121
|
}
|
|
84
|
-
};
|
|
85
|
-
if (destination instanceof Queue_1.Queue) {
|
|
86
|
-
exchange = "";
|
|
87
|
-
routingKey = destination.name;
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
exchange = destination.name;
|
|
91
122
|
}
|
|
92
|
-
destination.initialized.then(sendMessage);
|
|
93
123
|
}
|
|
94
124
|
ack(allUpTo) {
|
|
95
125
|
if (this._channel !== undefined) {
|
|
@@ -120,5 +150,4 @@ class Message {
|
|
|
120
150
|
}
|
|
121
151
|
}
|
|
122
152
|
}
|
|
123
|
-
exports.Message = Message;
|
|
124
153
|
//# sourceMappingURL=Message.js.map
|
package/lib/Message.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Message.js","sourceRoot":"","sources":["../src/Message.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Message.js","sourceRoot":"","sources":["../src/Message.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,OAAO,EAAE,qBAAqB,EAA6C,MAAM,SAAS,CAAC;AAE3F,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC;;GAEG;AACH,MAAM,OAAO,OAAO;IACX,MAAM,CAAM;IACnB;;;OAGG;IACI,QAAQ,CAAU;IACzB;;;OAGG;IACI,QAAQ,CAAc;IAC7B,iDAAiD;IAC1C,UAAU,CAAiB;IAClC,2CAA2C;IACpC,OAAO,CAAS;IAEvB;;;;;;;;OAQG;IACH,YAAY,OAAa,EAAE,UAA0B,EAAE;QACrD,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC;QAC1B,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;IAED;;;OAGG;IACI,UAAU;QACf,IAAI,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;QACtC,IAAI,IAAI,CAAC,UAAU,CAAC,WAAW,KAAK,kBAAkB,EAAE,CAAC;YACvD,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAChC,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;;;OAIG;IACI,cAAc;QACnB,IAAI,IAAI,CAAC,UAAU,CAAC,WAAW,KAAK,kBAAkB,EAAE,CAAC;YACvD,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;QAChF,CAAC;QAED,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAE,IAAI,CAAC,UAAU,CAAC,eAAkC,IAAI,OAAO,CAAC,CAAM,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O,EAAE,OAAO,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;IAEM,MAAM,CAAC,OAAO,GAAG,KAAK;QAC3B,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YAChC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;IAEO,UAAU,CAAC,OAAY;QAC7B,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;YAChC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACtC,CAAC;aAAM,IAAI,CAAC,CAAC,OAAO,YAAY,MAAM,CAAC,EAAE,CAAC;YACxC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;YACpD,IAAI,CAAC,UAAU,CAAC,WAAW,GAAG,kBAAkB,CAAC;YACjD,IAAI,CAAC,UAAU,CAAC,eAAe,GAAG,OAAO,CAAC;QAC5C,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACzB,CAAC;IACH,CAAC;CACF"}
|
package/lib/Queue/Queue.d.ts
CHANGED
|
@@ -1,31 +1,63 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { AmqpProperties } from "../AmqpProperties";
|
|
3
|
-
import { Binding } from "../Binding";
|
|
4
|
-
import { Connection } from "../Connection/Connection";
|
|
5
|
-
import { Exchange } from "../Exchange/Exchange";
|
|
6
|
-
import { Message } from "../Message";
|
|
7
|
-
import { DeclarationOptions } from "./DeclarationOptions";
|
|
8
|
-
import { DeleteResult } from "./DeleteResult";
|
|
9
|
-
import { InitializeResult } from "./InitializeResult";
|
|
10
|
-
import { StartConsumerResult } from "./StartConsumerResult";
|
|
1
|
+
import type { Options } from "amqplib";
|
|
2
|
+
import type { AmqpProperties } from "../AmqpProperties.js";
|
|
3
|
+
import { Binding } from "../Binding.js";
|
|
4
|
+
import { Connection } from "../Connection/Connection.js";
|
|
5
|
+
import { Exchange } from "../Exchange/Exchange.js";
|
|
6
|
+
import { Message } from "../Message.js";
|
|
7
|
+
import { DeclarationOptions } from "./DeclarationOptions.js";
|
|
8
|
+
import { DeleteResult } from "./DeleteResult.js";
|
|
9
|
+
import { InitializeResult } from "./InitializeResult.js";
|
|
10
|
+
import { StartConsumerResult } from "./StartConsumerResult.js";
|
|
11
11
|
/** Represents an AQMP queue. */
|
|
12
12
|
export declare class Queue {
|
|
13
13
|
connection: Connection;
|
|
14
14
|
private options;
|
|
15
|
-
/** A
|
|
15
|
+
/** A broker-side consumer cancel this soon after the consumer was registered again does not re-initialize. */
|
|
16
|
+
private static readonly CancelLoopWindowMs;
|
|
17
|
+
/**
|
|
18
|
+
* A promise that resolves once the connection is initialized and the queue is declared on its channel. It is
|
|
19
|
+
* replaced by a pending promise while the queue is re-initialized after a lost connection or a closed channel. It
|
|
20
|
+
* rejects when the queue fails on its own, or when the connection is closed or recovery gives up while it is pending.
|
|
21
|
+
*/
|
|
16
22
|
initialized: Promise<InitializeResult>;
|
|
17
|
-
/** The AMQP channel. */
|
|
18
|
-
_channel: AmqpLib.Channel;
|
|
19
|
-
/** A promise that resolves when a consumer handler is registered and initialized. */
|
|
20
|
-
_consumerInitialized: Promise<StartConsumerResult>;
|
|
21
23
|
private _name;
|
|
22
|
-
_consumer: (msg: any, channel?: AmqpLib.Channel) => any;
|
|
23
24
|
private _consumerOptions;
|
|
24
25
|
private _consumerTag;
|
|
25
26
|
private _consumerStopping;
|
|
26
27
|
private _deleting;
|
|
27
28
|
private _closing;
|
|
28
29
|
private log;
|
|
30
|
+
private _deferred;
|
|
31
|
+
private _consumerDeferred;
|
|
32
|
+
/** The generation of the last initialization, and that initialization. */
|
|
33
|
+
private _generation;
|
|
34
|
+
private _initializing;
|
|
35
|
+
/** Changes with every initialization, so a superseded one can tell. */
|
|
36
|
+
private _attempt;
|
|
37
|
+
/** The channel the queue was successfully declared on, and its model. */
|
|
38
|
+
private _readyChannel;
|
|
39
|
+
private _readyModel;
|
|
40
|
+
/** The channel the consumer is registered on, or being registered on. */
|
|
41
|
+
private _consumerChannel;
|
|
42
|
+
private _consuming;
|
|
43
|
+
/** The generation in which a broker-side consumer cancel made the queue re-initialize, until it re-consumed. */
|
|
44
|
+
private _cancelReinitGeneration;
|
|
45
|
+
/**
|
|
46
|
+
* When the current consumer was registered by a re-initialization after a broker-side cancel. Another cancel within
|
|
47
|
+
* {@link Queue.CancelLoopWindowMs} of that does not re-initialize again, which stops a cancel loop.
|
|
48
|
+
*/
|
|
49
|
+
private _cancelRecoveredAt;
|
|
50
|
+
/**
|
|
51
|
+
* The generation in which the broker refused the consumer. Registering it again on the same connection would be
|
|
52
|
+
* refused again, so it is only registered again after the next reconnect.
|
|
53
|
+
*/
|
|
54
|
+
private _consumerRefusedIn;
|
|
55
|
+
/** Why the queue failed on its own, after which it is no longer declared. */
|
|
56
|
+
private _failure;
|
|
57
|
+
/** Settles {@link _initializedChanged} for those waiting on it. */
|
|
58
|
+
private _changed;
|
|
59
|
+
/** Counts deliveries; bound once so it can be removed again. */
|
|
60
|
+
private readonly _onDelivery;
|
|
29
61
|
/** Returns the name of the queue. */
|
|
30
62
|
get name(): string;
|
|
31
63
|
/**
|
|
@@ -39,15 +71,35 @@ export declare class Queue {
|
|
|
39
71
|
* @constructor
|
|
40
72
|
*/
|
|
41
73
|
constructor(connection: Connection, name: string, options?: DeclarationOptions);
|
|
42
|
-
/**
|
|
43
|
-
|
|
74
|
+
/** Replaces a settled {@link initialized} with a pending one. */
|
|
75
|
+
private _pendInitialized;
|
|
76
|
+
/**
|
|
77
|
+
* Re-creates the channel after it closed while the connection stayed up, declares the queue again and restores its
|
|
78
|
+
* bindings, which a broker-side delete removes as well. Only then {@link initialized} resolves. The caller registers
|
|
79
|
+
* the consumer again.
|
|
80
|
+
*/
|
|
81
|
+
private _reinitialize;
|
|
82
|
+
private _declare;
|
|
83
|
+
/**
|
|
84
|
+
* Registers the consumer on the given channel. A refusal (for example 403 because another connection holds an
|
|
85
|
+
* exclusive consumer) is also reported through `error_connection`, since during recovery the consumer would
|
|
86
|
+
* otherwise stop silently.
|
|
87
|
+
*/
|
|
88
|
+
private _consume;
|
|
89
|
+
/** Cancels a consumer registration that completed after it was superseded, so it does not keep receiving messages. */
|
|
90
|
+
private _cancelSuperseded;
|
|
91
|
+
/**
|
|
92
|
+
* A channel that closes while the connection stays up (for example after a double ack) is re-created, the queue
|
|
93
|
+
* declared again and its consumer registered again. Closes during a failed declaration or consumer registration, on
|
|
94
|
+
* a lost connection or caused by {@link close} or {@link delete} are left alone.
|
|
95
|
+
*/
|
|
96
|
+
private _onChannelClose;
|
|
44
97
|
/**
|
|
45
98
|
* Directly sends a message to the underlying queue.
|
|
46
99
|
*
|
|
47
100
|
* @param message The AMQP message.
|
|
48
101
|
*/
|
|
49
102
|
send(message: Message): void;
|
|
50
|
-
rpc(requestParameters: any): Promise<Message>;
|
|
51
103
|
/**
|
|
52
104
|
* Sets the prefetch of the current quere. This limits the amount of unacknowledged messages on a channel. If you
|
|
53
105
|
* already specified this in the options in the constructor you don't need to set it here again.
|
|
@@ -67,16 +119,25 @@ export declare class Queue {
|
|
|
67
119
|
* @throws {Error} Rejects when a consumer is already bound to this queue.
|
|
68
120
|
* @returns A promise that resolves once the handler is bound to the queue.
|
|
69
121
|
*/
|
|
70
|
-
activateConsumer(onMessage: (msg: Message) => any, options?:
|
|
122
|
+
activateConsumer(onMessage: (msg: Message) => any, options?: Options.Consume & {
|
|
71
123
|
properties?: AmqpProperties;
|
|
72
124
|
}): Promise<StartConsumerResult>;
|
|
73
125
|
/**
|
|
74
|
-
*
|
|
75
|
-
* is
|
|
126
|
+
* Wraps the consumer handler for messages delivered on the given channel. A message that arrives after the consumer
|
|
127
|
+
* was stopped, before the broker confirmed the cancel, is given back to the queue for another consumer; one that
|
|
128
|
+
* needs no acknowledgement cannot be given back.
|
|
129
|
+
*/
|
|
130
|
+
private _createConsumerWrapper;
|
|
131
|
+
/**
|
|
132
|
+
* The broker cancelled the consumer, for example because the queue was deleted. The channel stays open, so nothing
|
|
133
|
+
* else would notice: close it, which re-declares the queue, restores its bindings and registers the consumer again
|
|
134
|
+
* through the channel close handling. A `noCreate` queue that is gone then fails like any failed declaration.
|
|
76
135
|
*/
|
|
77
|
-
|
|
136
|
+
private _onConsumerCancelled;
|
|
78
137
|
/**
|
|
79
|
-
* Completely removes the consumer handler and cancels the
|
|
138
|
+
* Completely removes the consumer handler and cancels the consumer on the broker. A consumer the broker refused has
|
|
139
|
+
* nothing to cancel, it is only removed. A consumer whose channel closes meanwhile is registered again on a new one,
|
|
140
|
+
* so that registration is waited for and cancelled instead.
|
|
80
141
|
*/
|
|
81
142
|
stopConsumer(): Promise<void>;
|
|
82
143
|
/**
|
|
@@ -96,12 +157,12 @@ export declare class Queue {
|
|
|
96
157
|
*/
|
|
97
158
|
bind(source: Exchange, pattern?: string, args?: any): Promise<Binding>;
|
|
98
159
|
/**
|
|
99
|
-
* Unbinds the queue from the given exchange by deleting the binding.
|
|
160
|
+
* Unbinds the queue from the given exchange by deleting the binding. Resolves right away if there is no such
|
|
161
|
+
* binding, for example because it was unbound before.
|
|
100
162
|
*
|
|
101
163
|
* @param source The exchange to unbind from.
|
|
102
164
|
* @param pattern The pattern the queue was bind with.
|
|
103
165
|
* @param _args Any additional arguments.
|
|
104
166
|
*/
|
|
105
167
|
unbind(source: Exchange, pattern?: string, _args?: any): Promise<void>;
|
|
106
|
-
private handleReceivedMessageEvent;
|
|
107
168
|
}
|