@droidsolutions-oss/amqp-ts 2.5.0 → 2.6.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 +23 -16
- package/lib/AmqpProperties.d.ts +81 -0
- package/lib/AmqpProperties.js +3 -0
- package/lib/AmqpProperties.js.map +1 -0
- package/lib/Binding.d.ts +18 -0
- package/lib/Binding.js +112 -0
- package/lib/Binding.js.map +1 -0
- package/lib/Connection/Connection.d.ts +109 -0
- package/lib/Connection/Connection.js +346 -0
- package/lib/Connection/Connection.js.map +1 -0
- package/lib/Connection/ConnectionMetrics.d.ts +7 -0
- package/lib/Connection/ConnectionMetrics.js +3 -0
- package/lib/Connection/ConnectionMetrics.js.map +1 -0
- package/lib/Connection/ReconnectStrategy.d.ts +4 -0
- package/lib/Connection/ReconnectStrategy.js +3 -0
- package/lib/Connection/ReconnectStrategy.js.map +1 -0
- package/lib/Connection/Topology.d.ts +19 -0
- package/lib/Connection/Topology.js +3 -0
- package/lib/Connection/Topology.js.map +1 -0
- package/lib/Exchange/DeclarationOptions.d.ts +20 -0
- package/lib/Exchange/DeclarationOptions.js +3 -0
- package/lib/Exchange/DeclarationOptions.js.map +1 -0
- package/lib/Exchange/Exchange.d.ts +94 -0
- package/lib/Exchange/Exchange.js +279 -0
- package/lib/Exchange/Exchange.js.map +1 -0
- package/lib/Exchange/ExchangeType.d.ts +6 -0
- package/lib/Exchange/ExchangeType.js +3 -0
- package/lib/Exchange/ExchangeType.js.map +1 -0
- package/lib/Exchange/InitializeResult.d.ts +3 -0
- package/lib/Exchange/InitializeResult.js +3 -0
- package/lib/Exchange/InitializeResult.js.map +1 -0
- package/lib/LoggerFactory.d.ts +48 -0
- package/lib/LoggerFactory.js +13 -0
- package/lib/LoggerFactory.js.map +1 -0
- package/lib/Message.d.ts +52 -0
- package/lib/Message.js +125 -0
- package/lib/Message.js.map +1 -0
- package/lib/Queue/DeclarationOptions.d.ts +18 -0
- package/lib/Queue/DeclarationOptions.js +3 -0
- package/lib/Queue/DeclarationOptions.js.map +1 -0
- package/lib/Queue/DeleteResult.d.ts +3 -0
- package/lib/Queue/DeleteResult.js +3 -0
- package/lib/Queue/DeleteResult.js.map +1 -0
- package/lib/Queue/InitializeResult.d.ts +5 -0
- package/lib/Queue/InitializeResult.js +3 -0
- package/lib/Queue/InitializeResult.js.map +1 -0
- package/lib/Queue/Queue.d.ts +107 -0
- package/lib/Queue/Queue.js +339 -0
- package/lib/Queue/Queue.js.map +1 -0
- package/lib/Queue/StartConsumerResult.d.ts +5 -0
- package/lib/Queue/StartConsumerResult.js +3 -0
- package/lib/Queue/StartConsumerResult.js.map +1 -0
- package/lib/amqp-ts.d.ts +9 -0
- package/lib/amqp-ts.js +21 -0
- package/lib/amqp-ts.js.map +1 -0
- package/lib/index.d.ts +14 -0
- package/lib/index.js +14 -0
- package/lib/index.js.map +1 -0
- package/package.json +36 -28
- package/CHANGELOG.md +0 -159
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Exchange = void 0;
|
|
4
|
+
const os = require("os");
|
|
5
|
+
const amqp_ts_1 = require("../amqp-ts");
|
|
6
|
+
const Binding_1 = require("../Binding");
|
|
7
|
+
const Message_1 = require("../Message");
|
|
8
|
+
/**
|
|
9
|
+
* Represents an exchange.
|
|
10
|
+
*/
|
|
11
|
+
class Exchange {
|
|
12
|
+
/**
|
|
13
|
+
* Initializes a new instance of the @see Exchange class.
|
|
14
|
+
*
|
|
15
|
+
* @summary Initializes an exchange by creating a channel and asserting the exchange exists on it. Once done the
|
|
16
|
+
* {@link initialized} promise will resolve.
|
|
17
|
+
* @param connection The AMQP connection.
|
|
18
|
+
* @param name The name of the exchange.
|
|
19
|
+
* @param type The type of the exchange.
|
|
20
|
+
* @param options Any declaration otions.
|
|
21
|
+
*/
|
|
22
|
+
constructor(connection, name, type, options = {}) {
|
|
23
|
+
this.connection = connection;
|
|
24
|
+
this.options = options;
|
|
25
|
+
this._consumer_handlers = new Array();
|
|
26
|
+
this._isConsumerInitializedRcp = false;
|
|
27
|
+
this.log = this.connection.loggerFactory(this.constructor, { exchange: name });
|
|
28
|
+
this._name = name;
|
|
29
|
+
this._type = type;
|
|
30
|
+
this._initialize();
|
|
31
|
+
}
|
|
32
|
+
/** Gets the name of the exchange. */
|
|
33
|
+
get name() {
|
|
34
|
+
return this._name;
|
|
35
|
+
}
|
|
36
|
+
/** Gets the type of the exchange. */
|
|
37
|
+
get type() {
|
|
38
|
+
return this._type;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Initializes the exchange and resolves the @see initialized promise once the initialization is complete.
|
|
42
|
+
*/
|
|
43
|
+
_initialize() {
|
|
44
|
+
this.initialized = new Promise((resolve, reject) => {
|
|
45
|
+
this.connection.initialized
|
|
46
|
+
.then(() => {
|
|
47
|
+
this.connection.connection.createChannel((createChannelError, channel) => {
|
|
48
|
+
/* istanbul ignore if */
|
|
49
|
+
if (createChannelError) {
|
|
50
|
+
reject(createChannelError);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
this._channel = channel;
|
|
54
|
+
const callback = (err, ok) => {
|
|
55
|
+
/* istanbul ignore if */
|
|
56
|
+
if (err) {
|
|
57
|
+
this.log.error({ err }, "Failed to create exchange '%s'.", this._name);
|
|
58
|
+
delete this.connection._exchanges[this._name];
|
|
59
|
+
reject(err);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
resolve(ok);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
if (this.options.noCreate) {
|
|
66
|
+
this._channel.checkExchange(this._name, callback);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
this._channel.assertExchange(this._name, this._type, this.options, callback);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
})
|
|
74
|
+
.catch((err) => {
|
|
75
|
+
this.log.warn({ err }, "Channel failure, error caused during connection!");
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
this.connection._exchanges[this._name] = this;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Directly sends a message to this exchange.
|
|
82
|
+
*
|
|
83
|
+
* @param message The message.
|
|
84
|
+
* @param routingKey The routing key of the message.
|
|
85
|
+
*/
|
|
86
|
+
send(message, routingKey = "") {
|
|
87
|
+
message.sendTo(this, routingKey);
|
|
88
|
+
}
|
|
89
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
90
|
+
rpc(requestParameters, routingKey = "", callback) {
|
|
91
|
+
return new Promise((resolve, reject) => {
|
|
92
|
+
function generateUuid() {
|
|
93
|
+
return Math.random().toString() + Math.random().toString() + Math.random().toString();
|
|
94
|
+
}
|
|
95
|
+
const processRpc = () => {
|
|
96
|
+
const uuid = generateUuid();
|
|
97
|
+
if (!this._isConsumerInitializedRcp) {
|
|
98
|
+
this._isConsumerInitializedRcp = true;
|
|
99
|
+
this._channel.consume(amqp_ts_1.DIRECT_REPLY_TO_QUEUE, (resultMsg) => {
|
|
100
|
+
const result = new Message_1.Message(resultMsg.content, resultMsg.properties);
|
|
101
|
+
result.fields = resultMsg.fields;
|
|
102
|
+
for (const handler of this._consumer_handlers) {
|
|
103
|
+
if (handler[0] === resultMsg.properties.correlationId) {
|
|
104
|
+
const func = handler[1];
|
|
105
|
+
func.apply("", [undefined, result]);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
resolve(result);
|
|
109
|
+
}, { noAck: true }, (err, _ok) => {
|
|
110
|
+
/* istanbul ignore if */
|
|
111
|
+
if (err) {
|
|
112
|
+
reject(new Error("amqp-ts: Queue.rpc error: " + err.message));
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
if (callback) {
|
|
116
|
+
// send the rpc request
|
|
117
|
+
this._consumer_handlers.push([uuid, callback]);
|
|
118
|
+
}
|
|
119
|
+
// consumerTag = ok.consumerTag;
|
|
120
|
+
const message = new Message_1.Message(requestParameters, {
|
|
121
|
+
correlationId: uuid,
|
|
122
|
+
replyTo: amqp_ts_1.DIRECT_REPLY_TO_QUEUE,
|
|
123
|
+
});
|
|
124
|
+
message.sendTo(this, routingKey);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
this._consumer_handlers.push([uuid, callback]);
|
|
130
|
+
const message = new Message_1.Message(requestParameters, {
|
|
131
|
+
correlationId: uuid,
|
|
132
|
+
replyTo: amqp_ts_1.DIRECT_REPLY_TO_QUEUE,
|
|
133
|
+
});
|
|
134
|
+
message.sendTo(this, routingKey);
|
|
135
|
+
resolve(message);
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
this.initialized.then(processRpc);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Removes any bindings of this exchange, deletes the exchange and then closes the channel.
|
|
143
|
+
*/
|
|
144
|
+
delete() {
|
|
145
|
+
if (this._deleting === undefined) {
|
|
146
|
+
this._deleting = new Promise((resolve, reject) => {
|
|
147
|
+
this.initialized
|
|
148
|
+
.then(() => {
|
|
149
|
+
return Binding_1.Binding.removeBindingsContaining(this);
|
|
150
|
+
})
|
|
151
|
+
.then(() => {
|
|
152
|
+
this._channel.deleteExchange(this._name, {}, (deleteExchangeError, _ok) => {
|
|
153
|
+
/* istanbul ignore if */
|
|
154
|
+
if (deleteExchangeError) {
|
|
155
|
+
reject(deleteExchangeError);
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
this._channel.close((channelCloseError) => {
|
|
159
|
+
delete this.initialized; // invalidate exchange
|
|
160
|
+
delete this.connection._exchanges[this._name]; // remove the exchange from our administration
|
|
161
|
+
/* istanbul ignore if */
|
|
162
|
+
if (channelCloseError) {
|
|
163
|
+
reject(channelCloseError);
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
delete this._channel;
|
|
167
|
+
delete this.connection;
|
|
168
|
+
resolve(null);
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
})
|
|
174
|
+
.catch((err) => {
|
|
175
|
+
reject(err);
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
return this._deleting;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Removes any bindings of this exchange and closes the channel.
|
|
183
|
+
*/
|
|
184
|
+
close() {
|
|
185
|
+
if (this._closing === undefined) {
|
|
186
|
+
this._closing = new Promise((resolve, reject) => {
|
|
187
|
+
this.initialized
|
|
188
|
+
.then(() => {
|
|
189
|
+
return Binding_1.Binding.removeBindingsContaining(this);
|
|
190
|
+
})
|
|
191
|
+
.then(() => {
|
|
192
|
+
delete this.initialized; // invalidate exchange
|
|
193
|
+
delete this.connection._exchanges[this._name]; // remove the exchange from our administration
|
|
194
|
+
this._channel.close((err) => {
|
|
195
|
+
/* istanbul ignore if */
|
|
196
|
+
if (err) {
|
|
197
|
+
reject(err);
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
delete this._channel;
|
|
201
|
+
delete this.connection;
|
|
202
|
+
resolve(null);
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
})
|
|
206
|
+
.catch((err) => {
|
|
207
|
+
reject(err);
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
return this._closing;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Creates a bew binding with this exchange to the given exchange.
|
|
215
|
+
*
|
|
216
|
+
* @param source The source exchange.
|
|
217
|
+
* @param pattern The pattern.
|
|
218
|
+
* @param args Any additonal arguments.
|
|
219
|
+
* @returns A promise that resolves when the binding is initialized.
|
|
220
|
+
*/
|
|
221
|
+
bind(source, pattern = "", args = {}) {
|
|
222
|
+
const binding = new Binding_1.Binding(this, source, pattern, args);
|
|
223
|
+
return binding.initialized;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Unbinds the given exchange from the connection.
|
|
227
|
+
*
|
|
228
|
+
* @param source The exchange to unbind from.
|
|
229
|
+
* @param pattern The pattern.
|
|
230
|
+
* @param _args Any addtional arguments.
|
|
231
|
+
*/
|
|
232
|
+
unbind(source, pattern = "", _args = {}) {
|
|
233
|
+
return this.connection._bindings[Binding_1.Binding.id(this, source, pattern)].delete();
|
|
234
|
+
}
|
|
235
|
+
/** Returns a string containing the name of the exchange, the name of the host and the process ID. */
|
|
236
|
+
consumerQueueName() {
|
|
237
|
+
return `${this._name}.${amqp_ts_1.ApplicationName}.${os.hostname()}.${process.pid}`;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Declares a queue, binds it to this exchange and activates the given consumer handler on the queue. The name of the
|
|
241
|
+
* queue is determined by the name of the exchange, the application, the host and the ID of the process. Calling this
|
|
242
|
+
* twice without @see stopConsumer between the calls will likely fail.
|
|
243
|
+
*
|
|
244
|
+
* @param onMessage The message handler.
|
|
245
|
+
* @param options Any consumer options. See
|
|
246
|
+
* @link https://www.squaremobius.net/amqp.node/channel_api.html#channel_consume for more information.
|
|
247
|
+
* @throws {Error} If a handler has already been registered for this queue.
|
|
248
|
+
*/
|
|
249
|
+
activateConsumer(onMessage, options) {
|
|
250
|
+
const queueName = this.consumerQueueName();
|
|
251
|
+
if (this.connection._queues[queueName]) {
|
|
252
|
+
return Promise.reject(new Error("amqp-ts Exchange.activateConsumer error: consumer already defined"));
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
const promises = [];
|
|
256
|
+
const queue = this.connection.declareQueue(queueName, { durable: false });
|
|
257
|
+
promises.push(queue.initialized);
|
|
258
|
+
const binding = queue.bind(this);
|
|
259
|
+
promises.push(binding);
|
|
260
|
+
const consumer = queue.activateConsumer(onMessage, options);
|
|
261
|
+
promises.push(consumer);
|
|
262
|
+
return Promise.all(promises);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Removes the bindings, the consumer and the queue if any exists.
|
|
267
|
+
*/
|
|
268
|
+
stopConsumer() {
|
|
269
|
+
const queue = this.connection._queues[this.consumerQueueName()];
|
|
270
|
+
if (queue) {
|
|
271
|
+
return queue.delete();
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
return Promise.resolve();
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
exports.Exchange = Exchange;
|
|
279
|
+
//# sourceMappingURL=Exchange.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Exchange.js","sourceRoot":"","sources":["../../src/Exchange/Exchange.ts"],"names":[],"mappings":";;;AAGA,yBAAyB;AACzB,wCAAoE;AACpE,wCAAqC;AAGrC,wCAAqC;AAKrC;;GAEG;AACH,MAAa,QAAQ;IAsBnB;;;;;;;;;OASG;IACH,YACS,UAAsB,EAC7B,IAAY,EACZ,IAAmB,EACX,UAA8B,EAAE;QAHjC,eAAU,GAAV,UAAU,CAAY;QAGrB,YAAO,GAAP,OAAO,CAAyB;QAtBlC,uBAAkB,GAAyB,IAAI,KAAK,EAAiB,CAAC;QACtE,8BAAyB,GAAG,KAAK,CAAC;QAuBxC,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QAE/E,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,WAAW,EAAE,CAAC;IACrB,CAAC;IAtCD,qCAAqC;IACrC,IAAW,IAAI;QACb,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IACD,qCAAqC;IACrC,IAAW,IAAI;QACb,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAiCD;;OAEG;IACI,WAAW;QAChB,IAAI,CAAC,WAAW,GAAG,IAAI,OAAO,CA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AAK,EAAE;YACT,OAAO,KAAK,CAAC,MAAM,EAAE,CAAC;SACvB;aAAM;YACL,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;SAC1B;IACH,CAAC;CACF;AApSD,4BAoSC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExchangeType.js","sourceRoot":"","sources":["../../src/Exchange/ExchangeType.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InitializeResult.js","sourceRoot":"","sources":["../../src/Exchange/InitializeResult.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A function that retrieves an instance of a logger.
|
|
3
|
+
*/
|
|
4
|
+
export interface LoggerFactory {
|
|
5
|
+
(context: Function | string, meta?: {
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
}): SimpleLogger;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A simple logger that logs messages.
|
|
11
|
+
*/
|
|
12
|
+
export interface SimpleLogger {
|
|
13
|
+
/** Logs with trace level. */
|
|
14
|
+
trace: LogFunction;
|
|
15
|
+
/** Logs with debug level. */
|
|
16
|
+
debug: LogFunction;
|
|
17
|
+
/** Logs with info level. */
|
|
18
|
+
info: LogFunction;
|
|
19
|
+
/** Logs with warn level. */
|
|
20
|
+
warn: LogFunction;
|
|
21
|
+
/** Logs with error level. */
|
|
22
|
+
error: LogFunction;
|
|
23
|
+
/** Logs with fatal level. */
|
|
24
|
+
fatal: LogFunction;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* A function that writes logs.
|
|
28
|
+
*/
|
|
29
|
+
interface LogFunction {
|
|
30
|
+
/**
|
|
31
|
+
* Logs a message template where %d, %s and %o are replaced by the given args in their order.
|
|
32
|
+
*/
|
|
33
|
+
(msg: string, ...args: any[]): void;
|
|
34
|
+
/**
|
|
35
|
+
* Logs an object with it's properties and a message template where %d, %s and %o are replaced by the given args in
|
|
36
|
+
* their order.
|
|
37
|
+
*/
|
|
38
|
+
(obj: Record<string, unknown>, msg?: string, ...args: any[]): void;
|
|
39
|
+
}
|
|
40
|
+
export declare class EmtpyLogger implements SimpleLogger {
|
|
41
|
+
trace(_obj: Record<string, unknown> | string, _msg?: string, ..._args: any[]): void;
|
|
42
|
+
debug(_obj: Record<string, unknown> | string, _msg?: string, ..._args: any[]): void;
|
|
43
|
+
info(_obj: Record<string, unknown> | string, _msg?: string, ..._args: any[]): void;
|
|
44
|
+
warn(_obj: Record<string, unknown> | string, _msg?: string, ..._args: any[]): void;
|
|
45
|
+
error(_obj: Record<string, unknown> | string, _msg?: string, ..._args: any[]): void;
|
|
46
|
+
fatal(_obj: Record<string, unknown> | string, _msg?: string, ..._args: any[]): void;
|
|
47
|
+
}
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EmtpyLogger = void 0;
|
|
4
|
+
class EmtpyLogger {
|
|
5
|
+
trace(_obj, _msg, ..._args) { }
|
|
6
|
+
debug(_obj, _msg, ..._args) { }
|
|
7
|
+
info(_obj, _msg, ..._args) { }
|
|
8
|
+
warn(_obj, _msg, ..._args) { }
|
|
9
|
+
error(_obj, _msg, ..._args) { }
|
|
10
|
+
fatal(_obj, _msg, ..._args) { }
|
|
11
|
+
}
|
|
12
|
+
exports.EmtpyLogger = EmtpyLogger;
|
|
13
|
+
//# sourceMappingURL=LoggerFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoggerFactory.js","sourceRoot":"","sources":["../src/LoggerFactory.ts"],"names":[],"mappings":";;;AA0CA,MAAa,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;AAPD,kCAOC"}
|
package/lib/Message.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import * as AmqpLib from "amqplib/callback_api";
|
|
3
|
+
import { AmqpProperties } from "./AmqpProperties";
|
|
4
|
+
import { Exchange } from "./Exchange/Exchange";
|
|
5
|
+
import { Queue } from "./Queue/Queue";
|
|
6
|
+
/**
|
|
7
|
+
* Represents a message that can be send via AMQP.
|
|
8
|
+
*/
|
|
9
|
+
export declare class Message {
|
|
10
|
+
fields: any;
|
|
11
|
+
/** for received messages only: the channel it has been received on */
|
|
12
|
+
_channel: AmqpLib.Channel;
|
|
13
|
+
/** received messages only: original amqplib message */
|
|
14
|
+
_message: AmqpLib.Message;
|
|
15
|
+
/** Additional AQMP properties of the message. */
|
|
16
|
+
properties: AmqpProperties;
|
|
17
|
+
/** The original contant of the message. */
|
|
18
|
+
content: Buffer;
|
|
19
|
+
/**
|
|
20
|
+
* Initializes a new instance of the @see Message class.
|
|
21
|
+
*
|
|
22
|
+
* If the given content is not a buffer or a string it will be converted to a json string and the content type will be
|
|
23
|
+
* set.
|
|
24
|
+
*
|
|
25
|
+
* @param content The message content.
|
|
26
|
+
* @param options The message options.
|
|
27
|
+
*/
|
|
28
|
+
constructor(content?: any, options?: AmqpProperties);
|
|
29
|
+
/**
|
|
30
|
+
* Returns the content of the message. If properties.contentType is set to "application/json" the content will be
|
|
31
|
+
* parsed. If not it will return the string that represents the buffer.
|
|
32
|
+
*/
|
|
33
|
+
getContent(): string | Record<string, unknown>;
|
|
34
|
+
/**
|
|
35
|
+
* Returns the content of the message parsed from json.
|
|
36
|
+
*
|
|
37
|
+
* @throws {Error} If the content type in the message properties is not set to application/json.
|
|
38
|
+
*/
|
|
39
|
+
getJsonContent<T>(): T;
|
|
40
|
+
/**
|
|
41
|
+
* Tries to publish the message on the destination channel. Appends the current @see properties object and the
|
|
42
|
+
* @see content of the message.
|
|
43
|
+
*
|
|
44
|
+
* @param destination The destination of the message.
|
|
45
|
+
* @param routingKey An optional routing key.
|
|
46
|
+
*/
|
|
47
|
+
sendTo(destination: Exchange | Queue, routingKey?: string): void;
|
|
48
|
+
ack(allUpTo?: boolean): void;
|
|
49
|
+
nack(allUpTo?: boolean, requeue?: boolean): void;
|
|
50
|
+
reject(requeue?: boolean): void;
|
|
51
|
+
private setContent;
|
|
52
|
+
}
|
package/lib/Message.js
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Message = void 0;
|
|
4
|
+
const Queue_1 = require("./Queue/Queue");
|
|
5
|
+
/**
|
|
6
|
+
* Represents a message that can be send via AMQP.
|
|
7
|
+
*/
|
|
8
|
+
class Message {
|
|
9
|
+
/**
|
|
10
|
+
* Initializes a new instance of the @see Message class.
|
|
11
|
+
*
|
|
12
|
+
* If the given content is not a buffer or a string it will be converted to a json string and the content type will be
|
|
13
|
+
* set.
|
|
14
|
+
*
|
|
15
|
+
* @param content The message content.
|
|
16
|
+
* @param options The message options.
|
|
17
|
+
*/
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
19
|
+
constructor(content, options = {}) {
|
|
20
|
+
this.properties = options;
|
|
21
|
+
if (content !== undefined) {
|
|
22
|
+
this.setContent(content);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Returns the content of the message. If properties.contentType is set to "application/json" the content will be
|
|
27
|
+
* parsed. If not it will return the string that represents the buffer.
|
|
28
|
+
*/
|
|
29
|
+
getContent() {
|
|
30
|
+
let content = this.content.toString();
|
|
31
|
+
if (this.properties.contentType === "application/json") {
|
|
32
|
+
content = JSON.parse(content);
|
|
33
|
+
}
|
|
34
|
+
return content;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Returns the content of the message parsed from json.
|
|
38
|
+
*
|
|
39
|
+
* @throws {Error} If the content type in the message properties is not set to application/json.
|
|
40
|
+
*/
|
|
41
|
+
getJsonContent() {
|
|
42
|
+
var _a;
|
|
43
|
+
if (this.properties.contentType !== "application/json") {
|
|
44
|
+
throw new Error("The content of the message is not set as application/json.");
|
|
45
|
+
}
|
|
46
|
+
return JSON.parse(this.content.toString((_a = this.properties.contentEncoding) !== null && _a !== void 0 ? _a : "utf-8"));
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Tries to publish the message on the destination channel. Appends the current @see properties object and the
|
|
50
|
+
* @see content of the message.
|
|
51
|
+
*
|
|
52
|
+
* @param destination The destination of the message.
|
|
53
|
+
* @param routingKey An optional routing key.
|
|
54
|
+
*/
|
|
55
|
+
sendTo(destination, routingKey = "") {
|
|
56
|
+
let exchange;
|
|
57
|
+
// inline function to send the message
|
|
58
|
+
const sendMessage = () => {
|
|
59
|
+
try {
|
|
60
|
+
if (!this.properties.timestamp) {
|
|
61
|
+
// Set timestamp if not set by user
|
|
62
|
+
this.properties.timestamp = Math.floor(new Date().getTime() / 1000);
|
|
63
|
+
}
|
|
64
|
+
destination._channel.publish(exchange, routingKey, this.content, this.properties);
|
|
65
|
+
destination.connection._increaseCounter("sentMessages");
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
const log = destination.connection.loggerFactory(this.constructor);
|
|
69
|
+
log.debug({ err }, "Publish error: %s", err.message);
|
|
70
|
+
const destinationName = destination.name;
|
|
71
|
+
const connection = destination.connection;
|
|
72
|
+
log.debug("Try to rebuild connection, before Call.");
|
|
73
|
+
connection._rebuildAll(err).then(() => {
|
|
74
|
+
log.debug("Retransmitting message.");
|
|
75
|
+
if (destination instanceof Queue_1.Queue) {
|
|
76
|
+
// connection._queues[destinationName].publish(this.content, this.properties);
|
|
77
|
+
connection._queues[destinationName].send(this);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
// connection._exchanges[destinationName].publish(this.content, routingKey, this.properties);
|
|
81
|
+
connection._exchanges[destinationName].send(this);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
if (destination instanceof Queue_1.Queue) {
|
|
87
|
+
exchange = "";
|
|
88
|
+
routingKey = destination.name;
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
exchange = destination.name;
|
|
92
|
+
}
|
|
93
|
+
destination.initialized.then(sendMessage);
|
|
94
|
+
}
|
|
95
|
+
ack(allUpTo) {
|
|
96
|
+
if (this._channel !== undefined) {
|
|
97
|
+
this._channel.ack(this._message, allUpTo);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
nack(allUpTo, requeue) {
|
|
101
|
+
if (this._channel !== undefined) {
|
|
102
|
+
this._channel.nack(this._message, allUpTo, requeue);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
reject(requeue = false) {
|
|
106
|
+
if (this._channel !== undefined) {
|
|
107
|
+
this._channel.reject(this._message, requeue);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
setContent(content) {
|
|
111
|
+
if (typeof content === "string") {
|
|
112
|
+
this.content = Buffer.from(content);
|
|
113
|
+
}
|
|
114
|
+
else if (!(content instanceof Buffer)) {
|
|
115
|
+
this.content = Buffer.from(JSON.stringify(content));
|
|
116
|
+
this.properties.contentType = "application/json";
|
|
117
|
+
this.properties.contentEncoding = "utf-8";
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
this.content = content;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
exports.Message = Message;
|
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eclarationOptions {
|
|
3
|
+
exclusive?: boolean;
|
|
4
|
+
durable?: boolean;
|
|
5
|
+
autoDelete?: boolean;
|
|
6
|
+
arguments?: any;
|
|
7
|
+
messageTtl?: number;
|
|
8
|
+
expires?: number;
|
|
9
|
+
deadLetterExchange?: string;
|
|
10
|
+
maxLength?: number;
|
|
11
|
+
/** Tells the server to not give more than this amount of messages at the same time to this queue. */
|
|
12
|
+
prefetch?: number;
|
|
13
|
+
/**
|
|
14
|
+
* If true, checkQueue is called instead of assertQueue. See
|
|
15
|
+
* {@link http://www.squaremobius.net/amqp.node/channel_api.html#channel_checkQueue} for more info.
|
|
16
|
+
*/
|
|
17
|
+
noCreate?: boolean;
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeclarationOptions.js","sourceRoot":"","sources":["../../src/Queue/DeclarationOptions.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeleteResult.js","sourceRoot":"","sources":["../../src/Queue/DeleteResult.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InitializeResult.js","sourceRoot":"","sources":["../../src/Queue/InitializeResult.ts"],"names":[],"mappings":""}
|