@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/Exchange/Exchange.js
CHANGED
|
@@ -1,14 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const amqp_ts_1 = require("../amqp-ts");
|
|
6
|
-
const Binding_1 = require("../Binding");
|
|
7
|
-
const Message_1 = require("../Message");
|
|
1
|
+
import * as os from "node:os";
|
|
2
|
+
import { ApplicationName } from "../amqp-ts.js";
|
|
3
|
+
import { Binding } from "../Binding.js";
|
|
4
|
+
import { Deferred } from "../Deferred.js";
|
|
8
5
|
/**
|
|
9
6
|
* Represents an exchange.
|
|
10
7
|
*/
|
|
11
|
-
class Exchange {
|
|
8
|
+
export class Exchange {
|
|
9
|
+
connection;
|
|
10
|
+
options;
|
|
11
|
+
/**
|
|
12
|
+
* A promise that resolves once the exchange is initialized. It is replaced by a pending promise while the exchange
|
|
13
|
+
* is re-initialized after a lost connection or a closed channel. It rejects when the exchange fails on its own, or
|
|
14
|
+
* when the connection is closed or recovery gives up while it is pending.
|
|
15
|
+
*/
|
|
16
|
+
initialized;
|
|
17
|
+
/**
|
|
18
|
+
* The underlying AMQP channel.
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
_channel;
|
|
12
22
|
/** Gets the name of the exchange. */
|
|
13
23
|
get name() {
|
|
14
24
|
return this._name;
|
|
@@ -17,6 +27,23 @@ class Exchange {
|
|
|
17
27
|
get type() {
|
|
18
28
|
return this._type;
|
|
19
29
|
}
|
|
30
|
+
_name;
|
|
31
|
+
_type;
|
|
32
|
+
_deleting;
|
|
33
|
+
_closing;
|
|
34
|
+
log;
|
|
35
|
+
_deferred;
|
|
36
|
+
/** The generation of the last initialization, and that initialization. */
|
|
37
|
+
_generation;
|
|
38
|
+
_initializing = Promise.resolve();
|
|
39
|
+
/** Changes with every initialization, so a superseded one can tell. */
|
|
40
|
+
_attempt = 0;
|
|
41
|
+
/** The channel the exchange was successfully declared on. */
|
|
42
|
+
_readyChannel;
|
|
43
|
+
/** Why the exchange failed on its own, after which it is no longer declared. */
|
|
44
|
+
_failure;
|
|
45
|
+
/** Settles {@link _initializedChanged} for those waiting on it. */
|
|
46
|
+
_changed;
|
|
20
47
|
/**
|
|
21
48
|
* Initializes a new instance of the @see Exchange class.
|
|
22
49
|
*
|
|
@@ -30,52 +57,161 @@ class Exchange {
|
|
|
30
57
|
constructor(connection, name, type, options = {}) {
|
|
31
58
|
this.connection = connection;
|
|
32
59
|
this.options = options;
|
|
33
|
-
this._consumer_handlers = new Array();
|
|
34
|
-
this._isConsumerInitializedRcp = false;
|
|
35
60
|
this.log = this.connection.loggerFactory(this.constructor, { exchange: name });
|
|
36
61
|
this._name = name;
|
|
37
62
|
this._type = type;
|
|
38
|
-
this.
|
|
63
|
+
this._deferred = this.connection._createDeferred();
|
|
64
|
+
this.initialized = this._deferred.promise;
|
|
65
|
+
this.connection._exchanges[this._name] = this;
|
|
66
|
+
this.connection._forgetFailure(this);
|
|
67
|
+
// while disconnected the next connect initializes it
|
|
68
|
+
if (this.connection._model) {
|
|
69
|
+
this._initialize(this.connection._model, this.connection._generation).catch(() => { });
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Creates a channel on the given model and declares the exchange on it, then settles {@link initialized}. Does
|
|
74
|
+
* nothing if the exchange was already initialized for the given generation.
|
|
75
|
+
* @internal
|
|
76
|
+
*/
|
|
77
|
+
_initialize(model, generation) {
|
|
78
|
+
if (this.connection._exchanges[this._name] !== this) {
|
|
79
|
+
// failed, closed or deleted: only a new declaration brings it back
|
|
80
|
+
return Promise.reject(this._failure ?? new Error(`Exchange '${this._name}' is no longer declared`));
|
|
81
|
+
}
|
|
82
|
+
if (this._generation !== generation) {
|
|
83
|
+
this._generation = generation;
|
|
84
|
+
this._initializing = this._declare(model, ++this._attempt);
|
|
85
|
+
}
|
|
86
|
+
return this._initializing;
|
|
39
87
|
}
|
|
40
88
|
/**
|
|
41
|
-
*
|
|
89
|
+
* Replaces a settled {@link initialized} with a pending one, until the exchange is initialized again.
|
|
90
|
+
* @internal
|
|
42
91
|
*/
|
|
43
|
-
|
|
44
|
-
this.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
92
|
+
_invalidate() {
|
|
93
|
+
this._readyChannel = undefined;
|
|
94
|
+
if (this._deferred.settled) {
|
|
95
|
+
this._deferred = this.connection._createDeferred();
|
|
96
|
+
this.initialized = this._deferred.promise;
|
|
97
|
+
this._notifyChanged();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Whether the exchange or its connection is closed or deleted on purpose, so nothing initializes it again.
|
|
102
|
+
* @internal
|
|
103
|
+
*/
|
|
104
|
+
get _isClosedOnPurpose() {
|
|
105
|
+
return this._closing !== undefined || this._deleting !== undefined || this.connection._isStopped;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Resolves once {@link initialized} is no longer the given promise, or once nothing will replace it any more
|
|
109
|
+
* because the exchange or its connection is closed or deleted. Used by a send whose channel turned out to be closing.
|
|
110
|
+
* @internal
|
|
111
|
+
*/
|
|
112
|
+
_initializedChanged(ready) {
|
|
113
|
+
if (this.initialized !== ready || this._isClosedOnPurpose) {
|
|
114
|
+
return Promise.resolve();
|
|
115
|
+
}
|
|
116
|
+
this._changed ??= new Deferred();
|
|
117
|
+
return this._changed.promise;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Wakes up whoever waits in {@link _initializedChanged}.
|
|
121
|
+
* @internal
|
|
122
|
+
*/
|
|
123
|
+
_notifyChanged() {
|
|
124
|
+
const changed = this._changed;
|
|
125
|
+
this._changed = undefined;
|
|
126
|
+
changed?.resolve();
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Rejects {@link initialized} if it is still pending. Used when the connection is closed or recovery gave up.
|
|
130
|
+
* @internal
|
|
131
|
+
*/
|
|
132
|
+
_rejectPending(err) {
|
|
133
|
+
if (!this._deferred.settled) {
|
|
134
|
+
this._deferred.reject(err);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Re-creates the channel after it closed while the connection stayed up, declares the exchange again and restores
|
|
139
|
+
* its bindings, which a broker-side delete removes as well. Only then {@link initialized} resolves, so a message
|
|
140
|
+
* sent after that is routed again.
|
|
141
|
+
*/
|
|
142
|
+
_reinitialize(model, generation) {
|
|
143
|
+
this._generation = generation;
|
|
144
|
+
this._initializing = this._declare(model, ++this._attempt, true);
|
|
145
|
+
return this._initializing;
|
|
146
|
+
}
|
|
147
|
+
async _declare(model, attempt, rebind = false) {
|
|
148
|
+
try {
|
|
149
|
+
const channel = await model.createChannel();
|
|
150
|
+
channel.on("error", (err) => {
|
|
151
|
+
this.log.warn({ err }, "Channel of exchange '%s' failed: %s", this._name, err.message);
|
|
76
152
|
});
|
|
153
|
+
channel.on("close", () => this._onChannelClose(channel, model));
|
|
154
|
+
if (attempt !== this._attempt) {
|
|
155
|
+
await channel.close().catch(() => { });
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
this._channel = channel;
|
|
159
|
+
const ok = this.options.noCreate
|
|
160
|
+
? await channel.checkExchange(this._name)
|
|
161
|
+
: await channel.assertExchange(this._name, this._type, this.options);
|
|
162
|
+
if (attempt !== this._attempt) {
|
|
163
|
+
await channel.close().catch(() => { });
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
this._readyChannel = channel;
|
|
167
|
+
if (rebind) {
|
|
168
|
+
await Binding._rebindContaining(this, model);
|
|
169
|
+
if (attempt !== this._attempt) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
// a reply and the connection's close can arrive together: never resolve on a closed connection
|
|
174
|
+
if (this.connection._isModelClosed(model)) {
|
|
175
|
+
throw new Error("Connection closed while the exchange was initialized");
|
|
176
|
+
}
|
|
177
|
+
this._deferred.resolve(ok);
|
|
178
|
+
}
|
|
179
|
+
catch (err) {
|
|
180
|
+
if (attempt !== this._attempt) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
if (this.connection._isModelClosed(model)) {
|
|
184
|
+
// the next connect initializes it again, until then initialized stays pending
|
|
185
|
+
this.log.debug({ err }, "Connection lost while initializing exchange '%s'.", this._name);
|
|
186
|
+
throw err;
|
|
187
|
+
}
|
|
188
|
+
this.log.error({ err }, "Failed to create exchange '%s'.", this._name);
|
|
189
|
+
delete this.connection._exchanges[this._name];
|
|
190
|
+
this._failure = err;
|
|
191
|
+
this._deferred.reject(err);
|
|
192
|
+
this.connection._onEntityFailed(this, err);
|
|
193
|
+
throw err;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* A channel that closes while the connection stays up (for example after a publish to an exchange that was deleted
|
|
198
|
+
* on the broker) is re-created and the exchange declared again. Closes during a failed declaration, on a lost
|
|
199
|
+
* connection or caused by {@link close} or {@link delete} are left alone.
|
|
200
|
+
*/
|
|
201
|
+
_onChannelClose(channel, model) {
|
|
202
|
+
if (channel !== this._readyChannel || this._closing !== undefined || this._deleting !== undefined) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
const generation = this._generation;
|
|
206
|
+
this._invalidate();
|
|
207
|
+
// the connection emits its own close right after closing its channels, so look at it once that happened
|
|
208
|
+
queueMicrotask(() => {
|
|
209
|
+
if (!this.connection._isModelUsable(model) || this._generation !== generation) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
this.log.warn("Channel of exchange '%s' closed, re-initializing it.", this._name);
|
|
213
|
+
this._reinitialize(model, generation).catch(() => { });
|
|
77
214
|
});
|
|
78
|
-
this.connection._exchanges[this._name] = this;
|
|
79
215
|
}
|
|
80
216
|
/**
|
|
81
217
|
* Directly sends a message to this exchange.
|
|
@@ -86,94 +222,19 @@ class Exchange {
|
|
|
86
222
|
send(message, routingKey = "") {
|
|
87
223
|
message.sendTo(this, routingKey);
|
|
88
224
|
}
|
|
89
|
-
rpc(requestParameters, routingKey = "", callback) {
|
|
90
|
-
return new Promise((resolve, reject) => {
|
|
91
|
-
function generateUuid() {
|
|
92
|
-
return Math.random().toString() + Math.random().toString() + Math.random().toString();
|
|
93
|
-
}
|
|
94
|
-
const processRpc = () => {
|
|
95
|
-
const uuid = generateUuid();
|
|
96
|
-
if (!this._isConsumerInitializedRcp) {
|
|
97
|
-
this._isConsumerInitializedRcp = true;
|
|
98
|
-
this._channel.consume(amqp_ts_1.DIRECT_REPLY_TO_QUEUE, (resultMsg) => {
|
|
99
|
-
const result = new Message_1.Message(resultMsg.content, resultMsg.properties);
|
|
100
|
-
result.fields = resultMsg.fields;
|
|
101
|
-
for (const handler of this._consumer_handlers) {
|
|
102
|
-
if (handler[0] === resultMsg.properties.correlationId) {
|
|
103
|
-
const func = handler[1];
|
|
104
|
-
func.apply("", [undefined, result]);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
resolve(result);
|
|
108
|
-
}, { noAck: true }, (err, _ok) => {
|
|
109
|
-
/* istanbul ignore if */
|
|
110
|
-
if (err) {
|
|
111
|
-
reject(new Error("amqp-ts: Queue.rpc error: " + err.message));
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
if (callback) {
|
|
115
|
-
// send the rpc request
|
|
116
|
-
this._consumer_handlers.push([uuid, callback]);
|
|
117
|
-
}
|
|
118
|
-
// consumerTag = ok.consumerTag;
|
|
119
|
-
const message = new Message_1.Message(requestParameters, {
|
|
120
|
-
correlationId: uuid,
|
|
121
|
-
replyTo: amqp_ts_1.DIRECT_REPLY_TO_QUEUE,
|
|
122
|
-
});
|
|
123
|
-
message.sendTo(this, routingKey);
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
this._consumer_handlers.push([uuid, callback]);
|
|
129
|
-
const message = new Message_1.Message(requestParameters, {
|
|
130
|
-
correlationId: uuid,
|
|
131
|
-
replyTo: amqp_ts_1.DIRECT_REPLY_TO_QUEUE,
|
|
132
|
-
});
|
|
133
|
-
message.sendTo(this, routingKey);
|
|
134
|
-
resolve(message);
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
this.initialized.then(processRpc);
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
225
|
/**
|
|
141
226
|
* Removes any bindings of this exchange, deletes the exchange and then closes the channel.
|
|
142
227
|
*/
|
|
143
228
|
delete() {
|
|
144
229
|
if (this._deleting === undefined) {
|
|
145
|
-
this._deleting =
|
|
146
|
-
this.
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
})
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
if (deleteExchangeError) {
|
|
154
|
-
reject(deleteExchangeError);
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
this._channel.close((channelCloseError) => {
|
|
158
|
-
delete this.initialized; // invalidate exchange
|
|
159
|
-
delete this.connection._exchanges[this._name]; // remove the exchange from our administration
|
|
160
|
-
/* istanbul ignore if */
|
|
161
|
-
if (channelCloseError) {
|
|
162
|
-
reject(channelCloseError);
|
|
163
|
-
}
|
|
164
|
-
else {
|
|
165
|
-
delete this._channel;
|
|
166
|
-
delete this.connection;
|
|
167
|
-
resolve(null);
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
})
|
|
173
|
-
.catch((err) => {
|
|
174
|
-
reject(err);
|
|
175
|
-
});
|
|
176
|
-
});
|
|
230
|
+
this._deleting = (async () => {
|
|
231
|
+
this._notifyChanged();
|
|
232
|
+
await this.initialized;
|
|
233
|
+
await Binding.removeBindingsContaining(this);
|
|
234
|
+
await this._channel.deleteExchange(this._name, {});
|
|
235
|
+
delete this.connection._exchanges[this._name]; // remove the exchange from our administration
|
|
236
|
+
await this._channel.close();
|
|
237
|
+
})();
|
|
177
238
|
}
|
|
178
239
|
return this._deleting;
|
|
179
240
|
}
|
|
@@ -182,30 +243,13 @@ class Exchange {
|
|
|
182
243
|
*/
|
|
183
244
|
close() {
|
|
184
245
|
if (this._closing === undefined) {
|
|
185
|
-
this._closing =
|
|
186
|
-
this.
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
delete this.connection._exchanges[this._name]; // remove the exchange from our administration
|
|
193
|
-
this._channel.close((err) => {
|
|
194
|
-
/* istanbul ignore if */
|
|
195
|
-
if (err) {
|
|
196
|
-
reject(err);
|
|
197
|
-
}
|
|
198
|
-
else {
|
|
199
|
-
delete this._channel;
|
|
200
|
-
delete this.connection;
|
|
201
|
-
resolve(null);
|
|
202
|
-
}
|
|
203
|
-
});
|
|
204
|
-
})
|
|
205
|
-
.catch((err) => {
|
|
206
|
-
reject(err);
|
|
207
|
-
});
|
|
208
|
-
});
|
|
246
|
+
this._closing = (async () => {
|
|
247
|
+
this._notifyChanged();
|
|
248
|
+
await this.initialized;
|
|
249
|
+
await Binding.removeBindingsContaining(this);
|
|
250
|
+
delete this.connection._exchanges[this._name]; // remove the exchange from our administration
|
|
251
|
+
await this._channel.close();
|
|
252
|
+
})();
|
|
209
253
|
}
|
|
210
254
|
return this._closing;
|
|
211
255
|
}
|
|
@@ -218,22 +262,24 @@ class Exchange {
|
|
|
218
262
|
* @returns A promise that resolves when the binding is initialized.
|
|
219
263
|
*/
|
|
220
264
|
bind(source, pattern = "", args = {}) {
|
|
221
|
-
const binding = new
|
|
265
|
+
const binding = new Binding(this, source, pattern, args);
|
|
222
266
|
return binding.initialized;
|
|
223
267
|
}
|
|
224
268
|
/**
|
|
225
|
-
* Unbinds the given exchange
|
|
269
|
+
* Unbinds this exchange from the given source exchange by deleting the binding. Resolves right away if there is no
|
|
270
|
+
* such binding, for example because it was unbound before.
|
|
226
271
|
*
|
|
227
272
|
* @param source The exchange to unbind from.
|
|
228
273
|
* @param pattern The pattern.
|
|
229
274
|
* @param _args Any addtional arguments.
|
|
230
275
|
*/
|
|
231
|
-
unbind(source, pattern = "", _args = {}) {
|
|
232
|
-
|
|
276
|
+
async unbind(source, pattern = "", _args = {}) {
|
|
277
|
+
// a binding that does not exist (any more) has nothing to delete
|
|
278
|
+
await this.connection._bindings[Binding.id(this, source, pattern)]?.delete();
|
|
233
279
|
}
|
|
234
280
|
/** Returns a string containing the name of the exchange, the name of the host and the process ID. */
|
|
235
281
|
consumerQueueName() {
|
|
236
|
-
return `${this._name}.${
|
|
282
|
+
return `${this._name}.${ApplicationName}.${os.hostname()}.${process.pid}`;
|
|
237
283
|
}
|
|
238
284
|
/**
|
|
239
285
|
* Declares a queue, binds it to this exchange and activates the given consumer handler on the queue. The name of the
|
|
@@ -274,5 +320,4 @@ class Exchange {
|
|
|
274
320
|
}
|
|
275
321
|
}
|
|
276
322
|
}
|
|
277
|
-
exports.Exchange = Exchange;
|
|
278
323
|
//# sourceMappingURL=Exchange.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Exchange.js","sourceRoot":"","sources":["../../src/Exchange/Exchange.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Exchange.js","sourceRoot":"","sources":["../../src/Exchange/Exchange.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9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|
|
4
|
-
class EmtpyLogger {
|
|
1
|
+
export class EmtpyLogger {
|
|
5
2
|
trace(_obj, _msg, ..._args) { }
|
|
6
3
|
debug(_obj, _msg, ..._args) { }
|
|
7
4
|
info(_obj, _msg, ..._args) { }
|
|
@@ -9,5 +6,4 @@ class EmtpyLogger {
|
|
|
9
6
|
error(_obj, _msg, ..._args) { }
|
|
10
7
|
fatal(_obj, _msg, ..._args) { }
|
|
11
8
|
}
|
|
12
|
-
exports.EmtpyLogger = EmtpyLogger;
|
|
13
9
|
//# sourceMappingURL=LoggerFactory.js.map
|
package/lib/LoggerFactory.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LoggerFactory.js","sourceRoot":"","sources":["../src/LoggerFactory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"LoggerFactory.js","sourceRoot":"","sources":["../src/LoggerFactory.ts"],"names":[],"mappings":"AAyCA,MAAM,OAAO,WAAW;IACtB,KAAK,CAAC,IAAsC,EAAE,IAAa,EAAE,GAAG,KAAY,IAAS,CAAC;IACtF,KAAK,CAAC,IAAsC,EAAE,IAAa,EAAE,GAAG,KAAY,IAAS,CAAC;IACtF,IAAI,CAAC,IAAsC,EAAE,IAAa,EAAE,GAAG,KAAY,IAAS,CAAC;IACrF,IAAI,CAAC,IAAsC,EAAE,IAAa,EAAE,GAAG,KAAY,IAAS,CAAC;IACrF,KAAK,CAAC,IAAsC,EAAE,IAAa,EAAE,GAAG,KAAY,IAAS,CAAC;IACtF,KAAK,CAAC,IAAsC,EAAE,IAAa,EAAE,GAAG,KAAY,IAAS,CAAC;CACvF"}
|
package/lib/Message.d.ts
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { Queue } from "./Queue/Queue";
|
|
1
|
+
import { AmqpProperties } from "./AmqpProperties.js";
|
|
2
|
+
import { Exchange } from "./Exchange/Exchange.js";
|
|
3
|
+
import { Queue } from "./Queue/Queue.js";
|
|
5
4
|
/**
|
|
6
5
|
* Represents a message that can be send via AMQP.
|
|
7
6
|
*/
|
|
8
7
|
export declare class Message {
|
|
9
8
|
fields: any;
|
|
10
|
-
/** for received messages only: the channel it has been received on */
|
|
11
|
-
_channel: AmqpLib.Channel;
|
|
12
|
-
/** received messages only: original amqplib message */
|
|
13
|
-
_message: AmqpLib.Message;
|
|
14
9
|
/** Additional AQMP properties of the message. */
|
|
15
10
|
properties: AmqpProperties;
|
|
16
11
|
/** The original contant of the message. */
|
|
@@ -37,13 +32,19 @@ export declare class Message {
|
|
|
37
32
|
*/
|
|
38
33
|
getJsonContent<T>(): T;
|
|
39
34
|
/**
|
|
40
|
-
*
|
|
41
|
-
* @see content of the message.
|
|
35
|
+
* Publishes the message on the destination's channel once the destination is initialized. Appends the current
|
|
36
|
+
* @see properties object and the @see content of the message.
|
|
37
|
+
*
|
|
38
|
+
* If the channel turns out to be closed or closing (the connection or the channel was lost, or amqplib is closing
|
|
39
|
+
* the connection after a protocol error), the message is published again once the destination is initialized
|
|
40
|
+
* again. A message that can never be published (the destination failed or was closed or deleted, recovery gave up
|
|
41
|
+
* or the connection was closed) is logged at warn level and dropped.
|
|
42
42
|
*
|
|
43
43
|
* @param destination The destination of the message.
|
|
44
44
|
* @param routingKey An optional routing key.
|
|
45
45
|
*/
|
|
46
46
|
sendTo(destination: Exchange | Queue, routingKey?: string): void;
|
|
47
|
+
private _publish;
|
|
47
48
|
ack(allUpTo?: boolean): void;
|
|
48
49
|
nack(allUpTo?: boolean, requeue?: boolean): void;
|
|
49
50
|
reject(requeue?: boolean): void;
|