@spinajs/queue-stomp-transport 2.0.481 → 2.0.482

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.
@@ -18,86 +18,405 @@ const queue_1 = require("@spinajs/queue");
18
18
  const stompjs_1 = __importDefault(require("@stomp/stompjs"));
19
19
  const lodash_1 = __importDefault(require("lodash"));
20
20
  const di_1 = require("@spinajs/di");
21
+ const util_1 = require("@spinajs/util");
21
22
  const websocket_1 = __importDefault(require("websocket"));
23
+ const crypto_1 = require("crypto");
24
+ const luxon_1 = require("luxon");
22
25
  Object.assign(global, { WebSocket: websocket_1.default.w3cwebsocket });
26
+ /**
27
+ * Default time to wait for a broker RECEIPT frame when publishing a message
28
+ * before the emit is considered failed. Can be overridden via `Options.receiptTimeout`.
29
+ */
30
+ const DEFAULT_RECEIPT_TIMEOUT_MS = 5000;
31
+ /**
32
+ * Time to wait for the initial STOMP connection before giving up.
33
+ * Can be overridden via `Options.connectionTimeout`.
34
+ */
35
+ const DEFAULT_CONNECTION_TIMEOUT_MS = 10000;
36
+ /**
37
+ * Default reconnect / heartbeat timings used when not provided in connection options.
38
+ *
39
+ * NOTE on heartbeats: the default ( 4s ) suits brokers that support STOMP heartbeats over
40
+ * WebSocket ( eg. ActiveMQ ). RabbitMQ Web-STOMP / SockJS does NOT support heartbeats - when
41
+ * targeting it, set `heartbeatIncoming` and `heartbeatOutgoing` to 0 in the connection options,
42
+ * otherwise the connection will be dropped. We keep 4s as the default so dead-connection
43
+ * detection still works on brokers that do support it.
44
+ */
45
+ const DEFAULT_RECONNECT_DELAY_MS = 5000;
46
+ const DEFAULT_HEARTBEAT_MS = 4000;
47
+ /**
48
+ * STOMP header carrying the number of times a job has already been retried.
49
+ * Set by this transport when it reschedules a failed job.
50
+ */
51
+ const RETRY_COUNT_HEADER = 'x-retry-count';
23
52
  let StompQueueClient = class StompQueueClient extends queue_1.QueueClient {
24
53
  get ClientId() {
25
54
  return this.Options.clientId ?? this.Options.name;
26
55
  }
56
+ /**
57
+ * `true` when there is an active connection with the broker.
58
+ */
59
+ get Connected() {
60
+ return this.Client?.connected ?? false;
61
+ }
62
+ get ReceiptTimeout() {
63
+ return this.Options.receiptTimeout ?? this.Options.options?.receiptTimeout ?? DEFAULT_RECEIPT_TIMEOUT_MS;
64
+ }
65
+ /**
66
+ * Resolves once the client is connected. If already connected resolves immediately,
67
+ * otherwise waits for the next ( re )connect, optionally bounded by `timeoutMs`.
68
+ */
69
+ whenReady(timeoutMs) {
70
+ if (this.Connected) {
71
+ return Promise.resolve();
72
+ }
73
+ return new Promise((resolve, reject) => {
74
+ let timer;
75
+ const waiter = () => {
76
+ if (timer) {
77
+ clearTimeout(timer);
78
+ }
79
+ resolve();
80
+ };
81
+ if (timeoutMs) {
82
+ timer = setTimeout(() => {
83
+ this.ReadyWaiters = this.ReadyWaiters.filter((w) => w !== waiter);
84
+ reject(new exceptions_1.UnexpectedServerError(`Timeout waiting for queue connection ${this.Options.name} to become ready`));
85
+ }, timeoutMs);
86
+ }
87
+ this.ReadyWaiters.push(waiter);
88
+ });
89
+ }
27
90
  constructor(options) {
28
91
  super(options);
29
92
  this.Subscriptions = new Map();
93
+ this.PendingEmits = [];
94
+ // resolvers waiting for the connection to come up ( see whenReady )
95
+ this.ReadyWaiters = [];
96
+ this.Disposing = false;
97
+ /** Publisher-side resilience: retry each receipt-confirmed publish with backoff so a transient
98
+ * broker hiccup / receipt timeout doesn't fail the emit. Duplicates are handled by consumer dedup. */
99
+ this.EmitPipeline = this.buildEmitPipeline();
100
+ }
101
+ /**
102
+ * Creates the underlying stompjs client. Extracted so it can be overridden
103
+ * ( e.g. with a fake ) in unit tests without a live broker.
104
+ */
105
+ createClient(config) {
106
+ return new stompjs_1.default.Client(config);
30
107
  }
31
108
  async resolve() {
32
109
  this.Log.info(`Connecting to STOMP queue at ${this.Options.host} with client-id: ${this.ClientId} ...`);
33
- this.Client = new stompjs_1.default.Client({
110
+ this.Client = this.createClient({
34
111
  brokerURL: this.Options.host,
35
112
  connectHeaders: {
36
113
  login: this.Options.login,
37
114
  passcode: this.Options.password,
38
115
  'client-id': this.ClientId,
39
116
  },
40
- reconnectDelay: 5000,
41
- heartbeatIncoming: 4000,
42
- heartbeatOutgoing: 4000,
43
- // additional options
117
+ reconnectDelay: this.Options.reconnectDelay ?? DEFAULT_RECONNECT_DELAY_MS,
118
+ heartbeatIncoming: this.Options.heartbeatIncoming ?? DEFAULT_HEARTBEAT_MS,
119
+ heartbeatOutgoing: this.Options.heartbeatOutgoing ?? DEFAULT_HEARTBEAT_MS,
120
+ connectionTimeout: this.Options.connectionTimeout ?? DEFAULT_CONNECTION_TIMEOUT_MS,
121
+ // additional options ( may override any of the defaults above )
44
122
  ...this.Options.options,
45
123
  });
46
124
  this.Client.debug = (str) => {
47
125
  this.Log.trace(`${str}, Client-id: ${this.ClientId}, name: ${this.Options.name}`);
48
126
  };
49
- return new Promise((resolve, reject) => {
50
- this.Client.onStompError = (frame) => {
51
- reject(new exceptions_1.UnexpectedServerError(`Cannot connect to queue server at ${this.Options.host}`, frame));
127
+ // if a credential provider is configured, refresh credentials right before
128
+ // every ( re )connect - supports rotating secrets / token based auth
129
+ if (this.Options.credentialProvider) {
130
+ this.Client.beforeConnect = async () => {
131
+ const provider = di_1.DI.resolve(this.Options.credentialProvider);
132
+ const creds = await provider.getCredentials(this.Options);
133
+ this.Client.connectHeaders = {
134
+ 'client-id': this.ClientId,
135
+ ...(creds.login ? { login: creds.login } : {}),
136
+ ...(creds.passcode ? { passcode: creds.passcode } : {}),
137
+ };
52
138
  };
139
+ }
140
+ // lifecycle handlers that simply log - installed once, never reassigned
141
+ this.Client.onUnhandledMessage = (message) => {
142
+ this.Log.warn(`Received unhandled message on ${message.headers?.destination ?? '<unknown>'} ( ${this.Options.name} ): ${message.body}`);
143
+ };
144
+ this.Client.onDisconnect = () => {
145
+ this.Log.warn(`Disconnected from STOMP client, client-id: ${this.ClientId}`);
146
+ };
147
+ this.Client.onWebSocketClose = () => {
148
+ this.Log.warn(`STOMP websocket closed, client-id: ${this.ClientId} ( will auto-reconnect if active )`);
149
+ };
150
+ return new Promise((resolve, reject) => {
151
+ // ensures we settle the initial-connect promise exactly once, and that a
152
+ // broker / websocket error only rejects BEFORE the first successful connect
153
+ let settled = false;
154
+ // onConnect fires on EVERY ( re )connect - this is where we replay
155
+ // subscriptions and flush buffered emits so the client survives drops
53
156
  this.Client.onConnect = () => {
54
157
  this.Log.success('Connected to STOMP client, client-id: ' + this.ClientId);
55
- resolve();
56
- // when connected override callbacks for loggin
57
- this.Client.onStompError = (frame) => {
58
- // Will be invoked in case of error encountered at Broker
59
- // Bad login/passcode typically will cause an error
60
- // Complaint brokers will set `message` header with a brief message. Body may contain details.
61
- // Compliant brokers will terminate the connection after any error
62
- this.Log.error('Broker reported error: ' + frame.headers['message']);
63
- this.Log.error('Additional details: ' + frame.body);
64
- };
65
- this.Client.onConnect = () => {
66
- this.Log.success('Connected to STOMP client');
67
- };
68
- this.Client.onDisconnect = () => {
69
- this.Log.warn('Disconnected to STOMP client');
70
- };
71
- this.Client.onWebSocketError = (err) => {
72
- this.Log.warn(err);
73
- };
158
+ for (const desc of this.Subscriptions.values()) {
159
+ this.applySubscription(desc);
160
+ }
161
+ this.flushPendingEmits();
162
+ this.flushReadyWaiters();
163
+ if (!settled) {
164
+ settled = true;
165
+ resolve();
166
+ }
167
+ };
168
+ this.Client.onStompError = (frame) => {
169
+ // Compliant brokers terminate the connection after an ERROR frame.
170
+ // Bad login / passcode typically surfaces here.
171
+ this.Log.error('Broker reported error: ' + frame.headers['message']);
172
+ this.Log.error('Additional details: ' + frame.body);
173
+ if (!settled) {
174
+ settled = true;
175
+ this.Client.deactivate();
176
+ reject(new exceptions_1.UnexpectedServerError(`Cannot connect to queue server at ${this.Options.host}`, frame));
177
+ }
74
178
  };
75
179
  this.Client.onWebSocketError = (err) => {
76
- this.Log.error(`Websocket error: ${JSON.stringify(err)}`);
77
- reject(new exceptions_1.UnexpectedServerError(`Cannot connect to queue server at ${this.Options.host}, websocket error`, err));
180
+ this.Log.error(`Websocket error: ${JSON.stringify(err)}, client-id: ${this.ClientId}`);
181
+ if (!settled) {
182
+ settled = true;
183
+ this.Client.deactivate();
184
+ reject(new exceptions_1.UnexpectedServerError(`Cannot connect to queue server at ${this.Options.host}, websocket error`, err));
185
+ }
78
186
  };
79
187
  this.Client.activate();
80
188
  });
81
189
  }
82
190
  async dispose() {
83
191
  this.Log.info(`Disposing queue connection ${this.Options.name} ...`);
84
- return new Promise((resolve) => {
85
- // if we dont have onDisconnect callback after 5sek, assume we have disconnected
86
- const t = setTimeout(() => {
87
- this.Log.warn('STOMP client deactivated, but was not connected before');
88
- resolve();
89
- }, 5000);
90
- this.Client.onDisconnect = () => {
91
- clearTimeout(t);
92
- resolve();
93
- this.Log.success('STOMP client deactivated');
94
- };
95
- this.Client.deactivate();
96
- });
192
+ this.Disposing = true;
193
+ // fail any still-buffered emits so callers awaiting them don't hang forever
194
+ const pending = this.PendingEmits;
195
+ this.PendingEmits = [];
196
+ for (const p of pending) {
197
+ p.reject(new exceptions_1.UnexpectedServerError(`Queue connection ${this.Options.name} disposed before message could be sent`));
198
+ }
199
+ if (!this.Client) {
200
+ return;
201
+ }
202
+ // deactivate() resolves once the underlying websocket is disposed
203
+ await this.Client.deactivate();
204
+ this.Log.success('STOMP client deactivated');
97
205
  }
98
206
  async emit(message) {
207
+ if (!this.Client?.connected) {
208
+ if (this.Disposing) {
209
+ throw new exceptions_1.UnexpectedServerError(`Cannot emit message, queue connection ${this.Options.name} is disposing`);
210
+ }
211
+ // not connected - buffer and flush on next ( re )connect
212
+ return new Promise((resolve, reject) => {
213
+ this.PendingEmits.push({ message, resolve, reject });
214
+ this.Log.warn(`Queue ${this.Options.name} not connected, message ${message.Name} buffered ( ${this.PendingEmits.length} pending )`);
215
+ });
216
+ }
217
+ return this.publishMessage(message);
218
+ }
219
+ unsubscribe(channelOrMessage, removeDurable = false) {
220
+ const channels = lodash_1.default.isString(channelOrMessage) ? [channelOrMessage] : this.getChannelForMessage(channelOrMessage);
221
+ channels.forEach((c) => {
222
+ const desc = this.Subscriptions.get(c);
223
+ if (!desc) {
224
+ return;
225
+ }
226
+ if (desc.durable && removeDurable && desc.subscriptionId) {
227
+ // delete the broker-side durable subscription, not just stop consuming.
228
+ // ActiveMQ removes a durable sub when UNSUBSCRIBE carries its subscription name.
229
+ this.Client.unsubscribe(desc.subscriptionId, { 'activemq.subscriptionName': desc.subscriptionId });
230
+ this.Log.info(`Removed durable subscription ${desc.subscriptionId} on channel ${c}`);
231
+ }
232
+ else {
233
+ desc.active?.unsubscribe();
234
+ }
235
+ this.Subscriptions.delete(c);
236
+ });
237
+ }
238
+ async subscribe(channelOrMessage, callback, subscriptionId, durable) {
239
+ const channels = lodash_1.default.isString(channelOrMessage) ? [channelOrMessage] : this.getChannelForMessage(channelOrMessage);
240
+ channels.forEach((c) => {
241
+ if (this.Subscriptions.has(c)) {
242
+ this.Log.warn(`Channel ${c} already subscribed !`);
243
+ return;
244
+ }
245
+ if (durable && !subscriptionId) {
246
+ throw new exceptions_1.InvalidArgument(`subscriptionId cannot be empty if using durable subscriptions`);
247
+ }
248
+ const desc = { channel: c, callback, subscriptionId, durable };
249
+ this.Subscriptions.set(c, desc);
250
+ // if already connected subscribe now, otherwise it will be applied on next onConnect
251
+ if (this.Client?.connected) {
252
+ this.applySubscription(desc);
253
+ }
254
+ else {
255
+ this.Log.info(`Channel ${c} recorded, will subscribe once connected`);
256
+ }
257
+ });
258
+ }
259
+ /**
260
+ * Creates the live broker subscription for a tracked descriptor.
261
+ * Called on initial subscribe and replayed for every descriptor on reconnect.
262
+ */
263
+ applySubscription(desc) {
264
+ const headers = { ack: 'client-individual', 'activemq.prefetchSize': '1' };
265
+ if (desc.subscriptionId) {
266
+ headers.id = desc.subscriptionId;
267
+ }
268
+ if (desc.durable) {
269
+ // durable subscriptions require a stable name ( guarded in subscribe() )
270
+ headers['activemq.subscriptionName'] = desc.subscriptionId;
271
+ }
272
+ desc.active = this.Client.subscribe(desc.channel, (message) => {
273
+ let qMessage;
274
+ try {
275
+ qMessage = JSON.parse(message.body);
276
+ }
277
+ catch (err) {
278
+ this.Log.error(`Cannot parse message body on channel ${desc.channel}: ${err.message}`);
279
+ this.handleUnparseableMessage(message, desc.channel, err);
280
+ return;
281
+ }
282
+ // luxon DateTime serializes to an ISO string over the wire - rehydrate it
283
+ if (typeof qMessage.CreatedAt === 'string') {
284
+ qMessage.CreatedAt = luxon_1.DateTime.fromISO(qMessage.CreatedAt);
285
+ }
286
+ desc
287
+ .callback(qMessage)
288
+ .then(() => {
289
+ message.ack();
290
+ })
291
+ .catch((err) => {
292
+ this.handleFailedMessage(message, qMessage, desc, err);
293
+ });
294
+ }, headers);
295
+ this.Log.success(`Channel ${desc.channel}, durable: ${desc.durable ? 'true' : 'false'} subscribed and ready to receive messages !`);
296
+ }
297
+ /**
298
+ * Handles a message whose consumer callback rejected.
299
+ *
300
+ * Events ( fire-and-forget ) are logged and acked ( dropped ) - the queue model
301
+ * does not retry them. Jobs are retried up to their RetryCount by re-publishing
302
+ * to the same channel with an incremented retry header ( and optional backoff ),
303
+ * then dead-lettered once retries are exhausted.
304
+ */
305
+ handleFailedMessage(message, qMessage, desc, err) {
306
+ const reason = err?.message ?? String(err);
307
+ // events are not retried or tracked - drop them
308
+ if (qMessage.Type !== queue_1.QueueMessageType.Job) {
309
+ this.Log.warn(`Event handler failed on channel ${desc.channel}, dropping message ${qMessage.Name}. ${reason}`);
310
+ message.ack();
311
+ return;
312
+ }
313
+ const maxRetries = qMessage.RetryCount ?? 0;
314
+ const attempt = Number(message.headers?.[RETRY_COUNT_HEADER] ?? '0');
315
+ if (attempt < maxRetries) {
316
+ const nextAttempt = attempt + 1;
317
+ const delay = this.retryBackoff(nextAttempt);
318
+ const headers = {
319
+ persistent: 'true',
320
+ 'content-type': 'application/json',
321
+ [RETRY_COUNT_HEADER]: `${nextAttempt}`,
322
+ };
323
+ // preserve app-relevant delivery headers across the retry republish.
324
+ // NOTE: original AMQ_SCHEDULED_* are intentionally dropped - the backoff delay below
325
+ // replaces scheduling for the retry ( we don't want to re-run a cron on a retry ).
326
+ if (qMessage.Priority) {
327
+ headers.priority = `${qMessage.Priority}`;
328
+ }
329
+ if (qMessage.JobId) {
330
+ headers['correlation-id'] = qMessage.JobId;
331
+ }
332
+ if (delay > 0) {
333
+ headers['AMQ_SCHEDULED_DELAY'] = `${delay}`;
334
+ }
335
+ try {
336
+ // ack the original and reschedule a fresh delivery to the same channel
337
+ this.Client.publish({ destination: desc.channel, body: message.body, headers });
338
+ message.ack();
339
+ this.Log.warn(`Job ${qMessage.Name} failed on ${desc.channel}, retry ${nextAttempt}/${maxRetries} scheduled in ${delay}ms. ${reason}`);
340
+ }
341
+ catch (retryErr) {
342
+ this.Log.error(`Failed to reschedule job ${qMessage.Name} on ${desc.channel}, nacking instead: ${retryErr.message}`);
343
+ message.nack();
344
+ }
345
+ return;
346
+ }
347
+ // retries exhausted - route to dead-letter
348
+ this.deadLetter(message, this.getDeadLetterChannelForMessage(qMessage), desc.channel, reason, attempt);
349
+ }
350
+ /**
351
+ * Handles a message whose body could not be parsed as JSON. It cannot be retried
352
+ * ( we don't know its type ), so it is dead-lettered or nacked.
353
+ */
354
+ handleUnparseableMessage(message, channel, err) {
355
+ const reason = err?.message ?? String(err);
356
+ this.deadLetter(message, this.Options.defaultQueueDeadLetterChannel, channel, reason);
357
+ }
358
+ /**
359
+ * Publishes a failed message to the given dead-letter channel and acks the original
360
+ * to unblock the source queue. When no dead-letter channel is configured the message is
361
+ * dropped ( acked ) with a warning - we never nack-loop a poison message forever.
362
+ */
363
+ deadLetter(message, dlq, channel, reason, attempt) {
364
+ if (!dlq) {
365
+ // retries are already exhausted here; nacking would just redeliver into another exhausted
366
+ // cycle forever. Drop it ( ack ) with a loud warning so the source queue is unblocked.
367
+ this.Log.warn(`Message failed on channel ${channel}, retries exhausted and no dead-letter channel configured - dropping. ${reason}`);
368
+ message.ack();
369
+ return;
370
+ }
371
+ try {
372
+ const headers = {
373
+ persistent: 'true',
374
+ 'content-type': 'application/json',
375
+ 'x-original-destination': channel,
376
+ 'x-error': reason,
377
+ };
378
+ if (attempt !== undefined) {
379
+ headers[RETRY_COUNT_HEADER] = `${attempt}`;
380
+ }
381
+ this.Client.publish({ destination: dlq, body: message.body, headers });
382
+ message.ack();
383
+ this.Log.warn(`Message failed on channel ${channel}, routed to dead-letter ${dlq}. ${reason}`);
384
+ }
385
+ catch (dlqErr) {
386
+ this.Log.error(`Failed to route message to dead-letter ${dlq}, nacking instead: ${dlqErr.message}`);
387
+ message.nack();
388
+ }
389
+ }
390
+ /**
391
+ * Exponential backoff ( ms ) for the given retry attempt, based on `Options.retryDelay`.
392
+ * Returns 0 ( immediate redelivery ) when no base delay is configured.
393
+ */
394
+ retryBackoff(attempt) {
395
+ const base = this.Options.retryDelay ?? 0;
396
+ return base > 0 ? base * 2 ** (attempt - 1) : 0;
397
+ }
398
+ /**
399
+ * Publisher-side resilience pipeline used by emit(). Retries a failed / timed-out receipt
400
+ * publish with exponential backoff ( the per-attempt timeout lives in publishWithReceipt ).
401
+ */
402
+ buildEmitPipeline() {
403
+ const attempts = this.Options.options?.emitRetries ?? 3;
404
+ const base = this.Options.retryDelay && this.Options.retryDelay > 0 ? this.Options.retryDelay : 200;
405
+ return new util_1.ResiliencePipelineBuilder()
406
+ .addRetry({ MaxRetryAttempts: attempts, Delay: base, MaxDelay: 30000, BackoffType: util_1.BackoffType.Exponential, UseJitter: true })
407
+ .build();
408
+ }
409
+ /**
410
+ * Publishes a message to all of its routed channels and resolves only once the
411
+ * broker has acknowledged each publish with a RECEIPT frame.
412
+ */
413
+ publishMessage(message) {
99
414
  const channels = this.getChannelForMessage(message);
100
- const headers = {};
415
+ const headers = { 'content-type': 'application/json' };
416
+ // tie jobs to their JobModel row for broker-side traceability
417
+ if (message.JobId) {
418
+ headers['correlation-id'] = message.JobId;
419
+ }
101
420
  if (message.Persistent) {
102
421
  headers['persistent'] = 'true';
103
422
  }
@@ -116,55 +435,58 @@ let StompQueueClient = class StompQueueClient extends queue_1.QueueClient {
116
435
  if (message.ScheduleRepeat) {
117
436
  headers['AMQ_SCHEDULED_REPEAT'] = message.ScheduleRepeat.toString();
118
437
  }
119
- channels.forEach((c) => {
438
+ const body = JSON.stringify(message);
439
+ return Promise.all(channels.map((c) => this.EmitPipeline.execute(() => this.publishWithReceipt(c, body, headers, message)))).then(() => undefined);
440
+ }
441
+ /**
442
+ * Publishes to a single channel and waits for the broker RECEIPT frame so the
443
+ * caller gets real delivery confirmation ( bounded by `ReceiptTimeout` ).
444
+ */
445
+ publishWithReceipt(channel, body, headers, message) {
446
+ return new Promise((resolve, reject) => {
447
+ const receiptId = (0, crypto_1.randomUUID)();
448
+ let timer;
449
+ this.Client.watchForReceipt(receiptId, () => {
450
+ clearTimeout(timer);
451
+ this.Log.trace(`Published ${message.Type} Name: ${message.Name} to channel ${channel} ( ${this.Options.name} )`);
452
+ resolve();
453
+ });
454
+ timer = setTimeout(() => {
455
+ reject(new exceptions_1.UnexpectedServerError(`Timeout waiting for broker receipt while publishing to ${channel} ( ${this.Options.name} )`));
456
+ }, this.ReceiptTimeout);
120
457
  this.Client.publish({
121
- destination: c,
122
- body: JSON.stringify(message),
123
- headers,
458
+ destination: channel,
459
+ body,
460
+ headers: { ...headers, receipt: receiptId },
124
461
  });
125
- this.Log.trace(`Published ${message.Type} Name: ${message.Name} to channel ${c} ( ${this.Options.name} )`);
126
462
  });
127
463
  }
128
- unsubscribe(channelOrMessage) {
129
- const channels = lodash_1.default.isString(channelOrMessage) ? [channelOrMessage] : this.getChannelForMessage(channelOrMessage);
130
- channels.forEach((c) => {
131
- if (!this.Subscriptions.has(c)) {
132
- return;
133
- }
134
- this.Subscriptions.get(c).unsubscribe();
135
- this.Subscriptions.delete(c);
136
- });
464
+ /**
465
+ * Flushes messages buffered while disconnected. Called from `onConnect`.
466
+ */
467
+ flushPendingEmits() {
468
+ if (this.PendingEmits.length === 0) {
469
+ return;
470
+ }
471
+ const pending = this.PendingEmits;
472
+ this.PendingEmits = [];
473
+ this.Log.info(`Flushing ${pending.length} buffered message(s) for queue ${this.Options.name}`);
474
+ for (const p of pending) {
475
+ this.publishMessage(p.message).then(p.resolve).catch(p.reject);
476
+ }
137
477
  }
138
- async subscribe(channelOrMessage, callback, subscriptionId, durable) {
139
- const channels = lodash_1.default.isString(channelOrMessage) ? [channelOrMessage] : this.getChannelForMessage(channelOrMessage);
140
- channels.forEach((c) => {
141
- if (this.Subscriptions.has(c)) {
142
- this.Log.warn(`Channel ${c} already subscribed !`);
143
- return;
144
- }
145
- const headers = { ack: 'client', 'activemq.prefetchSize': '1' };
146
- if (subscriptionId) {
147
- headers.id = subscriptionId;
148
- }
149
- if (durable) {
150
- if (!subscriptionId) {
151
- throw new exceptions_1.InvalidArgument(`subscriptionId cannot be empty if using durable subscriptions`);
152
- }
153
- headers['activemq.subscriptionName'] = subscriptionId;
154
- }
155
- const subscription = this.Client.subscribe(c, (message) => {
156
- const qMessage = JSON.parse(message.body);
157
- callback(qMessage)
158
- .then(() => {
159
- message.ack();
160
- })
161
- .catch(() => {
162
- message.nack();
163
- });
164
- }, headers);
165
- this.Subscriptions.set(c, subscription);
166
- this.Log.success(`Channel ${c}, durable: ${durable ? 'true' : 'false'} subscribed and ready to receive messages !`);
167
- });
478
+ /**
479
+ * Resolves everyone waiting on {@link whenReady}. Called from `onConnect`.
480
+ */
481
+ flushReadyWaiters() {
482
+ if (this.ReadyWaiters.length === 0) {
483
+ return;
484
+ }
485
+ const waiters = this.ReadyWaiters;
486
+ this.ReadyWaiters = [];
487
+ for (const w of waiters) {
488
+ w();
489
+ }
168
490
  }
169
491
  };
170
492
  exports.StompQueueClient = StompQueueClient;
@@ -1 +1 @@
1
- {"version":3,"file":"connection.js","sourceRoot":"","sources":["../../src/connection.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oDAA6E;AAC7E,0CAAmG;AACnG,6DA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AE;aAC5C,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACO,iBAAiB;QACzB,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACnC,OAAO;QACT,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC;QAClC,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC;QAEvB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,OAAO,CAAC,MAAM,kCAAkC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;QAE/F,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;YACxB,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QACjE,CAAC;IACH,CAAC;IAED;;OAEG;IACO,iBAAiB;QACzB,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACnC,OAAO;QACT,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC;QAClC,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC;QAEvB,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;YACxB,CAAC,EAAE,CAAC;QACN,CAAC;IACH,CAAC;CACF,CAAA;AA9hBY,4CAAgB;2BAAhB,gBAAgB;IAF5B,IAAA,qBAAgB,GAAE;IAClB,IAAA,eAAU,EAAC,mBAAW,CAAC;;GACX,gBAAgB,CA8hB5B"}
@@ -1,3 +1,3 @@
1
- export * from "./connection-factory.js";
2
- export * from "./connection.js";
1
+ export * from './connection-factory.js';
2
+ export * from './connection.js';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1,6 +1,7 @@
1
1
  import { DI } from '@spinajs/di';
2
2
  import { StompQueueClient } from './connection.js';
3
3
  import { Configuration } from '@spinajs/configuration';
4
+ import { InvalidOperation } from '@spinajs/exceptions';
4
5
  /**
5
6
  * Create factory func that sets client-id to connection by app name.
6
7
  * We cannot have two connection with same ID, so by default we take app-name
@@ -11,8 +12,11 @@ import { Configuration } from '@spinajs/configuration';
11
12
  */
12
13
  DI.register(async (container, options) => {
13
14
  const cfg = container.get(Configuration);
14
- const appName = cfg.get("app.name", "no-app");
15
- const env = cfg.get("process.env.APP_ENV", "development");
15
+ if (!cfg) {
16
+ throw new InvalidOperation('Configuration service is not available, cannot resolve STOMP queue connection');
17
+ }
18
+ const appName = cfg.get('app.name', 'no-app');
19
+ const env = cfg.get('process.env.APP_ENV', 'development');
16
20
  const c = new StompQueueClient({
17
21
  ...options,
18
22
  clientId: `${appName}-${env}-${options.name}`,
@@ -1 +1 @@
1
- {"version":3,"file":"connection-factory.js","sourceRoot":"","sources":["../../src/connection-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD;;;;;;;GAOG;AACH,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,EAAE,OAAgC,EAAE,EAAE;IAEhE,MAAM,GAAG,GAAG,SAAS,CAAC,GAAG,CAAC,aAAa,CAAE,CAAC;IAC1C,MAAM,OAAO,GAAG,GAAG,CAAC,GAAG,CAAS,UAAU,EAAC,QAAQ,CAAC,CAAC;IACrD,MAAM,GAAG,GAAG,GAAG,CAAC,GAAG,CAAS,qBAAqB,EAAE,aAAa,CAAC,CAAC;IAElE,MAAM,CAAC,GAAG,IAAI,gBAAgB,CAAC;QAC7B,GAAG,OAAO;QACV,QAAQ,EAAE,GAAG,OAAO,IAAI,GAAG,IAAI,OAAO,CAAC,IAAI,EAAE;KAC9C,CAAC,CAAC;IACH,MAAM,CAAC,CA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