@autofleet/rabbit 3.4.0-beta.5 → 3.4.0-beta.7

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.
Files changed (3) hide show
  1. package/dist/index.js +19 -17
  2. package/package.json +1 -1
  3. package/src/index.ts +22 -22
package/dist/index.js CHANGED
@@ -322,7 +322,7 @@ class RabbitMq {
322
322
  logger_1.default.error(`rabbit: error on get connection for new channel ${name} `, { e });
323
323
  throw e;
324
324
  }
325
- const channel = localConnection.createChannel({ ...options });
325
+ const channel = localConnection?.createChannel({ ...options });
326
326
  (0, events_1.once)(channel, 'close').then((args) => {
327
327
  logger_1.default.error(`rabbit: channel ${name} closed`);
328
328
  onClose?.(args);
@@ -617,22 +617,24 @@ class RabbitMq {
617
617
  ]);
618
618
  });
619
619
  }
620
- // TODO: [QUORUM-PHASE-3] Delete the old implementation
621
- await this.saveConsumerOld(queue, callback, options);
622
- const channelOld = await this.getNewChannelOld({
623
- name: `consume-exchange-${exchange}-queue-${queue}-old`,
624
- connection: this.oldConsumeConnection,
625
- });
626
- await channelOld.addSetup(async (c) => {
627
- const assertExchange = await (0, utils_1.assertExchangeFanout)(c, exchange);
628
- await c.assertQueue(queue);
629
- this.oldExchanges[exchange] = assertExchange;
630
- await c.prefetch(limit, false);
631
- return Promise.all([
632
- c.bindQueue(queue, exchange, ''),
633
- this.consumeOld(queue, callback, options),
634
- ]);
635
- });
620
+ else {
621
+ // TODO: [QUORUM-PHASE-3] Delete the old implementation
622
+ await this.saveConsumerOld(queue, callback, options);
623
+ const channelOld = await this.getNewChannelOld({
624
+ name: `consume-exchange-${exchange}-queue-${queue}-old`,
625
+ connection: this.oldConsumeConnection,
626
+ });
627
+ await channelOld.addSetup(async (c) => {
628
+ const assertExchange = await (0, utils_1.assertExchangeFanout)(c, exchange);
629
+ await c.assertQueue(queue);
630
+ this.oldExchanges[exchange] = assertExchange;
631
+ await c.prefetch(limit, false);
632
+ return Promise.all([
633
+ c.bindQueue(queue, exchange, ''),
634
+ this.consumeOld(queue, callback, options),
635
+ ]);
636
+ });
637
+ }
636
638
  }
637
639
  // Used by the microservices to publish messages to the exchange
638
640
  // TODO: [QUORUM-PHASE-2] Change the implementation to the new one
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/rabbit",
3
- "version": "3.4.0-beta.5",
3
+ "version": "3.4.0-beta.7",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "engines": {
package/src/index.ts CHANGED
@@ -513,7 +513,7 @@ class RabbitMq implements IAfRabbitMq {
513
513
  logger.error(`rabbit: error on get connection for new channel ${name} `, { e });
514
514
  throw e;
515
515
  }
516
- const channel = localConnection.createChannel({ ...options });
516
+ const channel = localConnection?.createChannel({ ...options });
517
517
  once(channel, 'close').then((args) => {
518
518
  logger.error(`rabbit: channel ${name} closed`);
519
519
  onClose?.(args);
@@ -853,28 +853,28 @@ class RabbitMq implements IAfRabbitMq {
853
853
  ),
854
854
  ]);
855
855
  });
856
+ } else {
857
+ // TODO: [QUORUM-PHASE-3] Delete the old implementation
858
+ await this.saveConsumerOld(queue, callback, options);
859
+ const channelOld: ChannelWrapper = await this.getNewChannelOld({
860
+ name: `consume-exchange-${exchange}-queue-${queue}-old`,
861
+ connection: this.oldConsumeConnection,
862
+ });
863
+ await channelOld.addSetup(async (c: ConfirmChannel) => {
864
+ const assertExchange = await assertExchangeFanout(c, exchange);
865
+ await c.assertQueue(queue);
866
+ this.oldExchanges[exchange] = assertExchange;
867
+ await c.prefetch(limit, false);
868
+ return Promise.all([
869
+ c.bindQueue(queue, exchange, ''),
870
+ this.consumeOld(
871
+ queue,
872
+ callback,
873
+ options,
874
+ ),
875
+ ]);
876
+ });
856
877
  }
857
-
858
- // TODO: [QUORUM-PHASE-3] Delete the old implementation
859
- await this.saveConsumerOld(queue, callback, options);
860
- const channelOld: ChannelWrapper = await this.getNewChannelOld({
861
- name: `consume-exchange-${exchange}-queue-${queue}-old`,
862
- connection: this.oldConsumeConnection,
863
- });
864
- await channelOld.addSetup(async (c: ConfirmChannel) => {
865
- const assertExchange = await assertExchangeFanout(c, exchange);
866
- await c.assertQueue(queue);
867
- this.oldExchanges[exchange] = assertExchange;
868
- await c.prefetch(limit, false);
869
- return Promise.all([
870
- c.bindQueue(queue, exchange, ''),
871
- this.consumeOld(
872
- queue,
873
- callback,
874
- options,
875
- ),
876
- ]);
877
- });
878
878
  }
879
879
 
880
880
  // Used by the microservices to publish messages to the exchange