@rxdi/rabbitmq-pubsub 0.7.225 → 0.7.227

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/dist/common.d.ts CHANGED
@@ -19,6 +19,9 @@ export interface IQueueNameConfig {
19
19
  dlq: string;
20
20
  dlx: string;
21
21
  strictName?: boolean;
22
+ arguments?: {
23
+ [key: string]: any;
24
+ };
22
25
  }
23
26
  export declare class DefaultQueueNameConfig implements IQueueNameConfig {
24
27
  name: string;
@@ -34,3 +37,7 @@ export declare class DefaultPubSubQueueConfig implements IQueueNameConfig {
34
37
  }
35
38
  export declare function asQueueNameConfig(config: IQueueNameConfig | string): IQueueNameConfig;
36
39
  export declare function asPubSubQueueNameConfig(config: IQueueNameConfig | string): IQueueNameConfig;
40
+ export interface IDeadLetterMessage<T> {
41
+ data: T;
42
+ error: Error;
43
+ }
package/dist/index.d.ts CHANGED
@@ -3,4 +3,4 @@ export { RabbitMqConsumer, IRabbitMqConsumerDisposer } from "./consumer";
3
3
  export { RabbitMqProducer } from "./producer";
4
4
  export { RabbitMqPublisher } from "./publisher";
5
5
  export { RabbitMqSubscriber, IRabbitMqSubscriberDisposer } from "./subscriber";
6
- export { IQueueNameConfig } from "./common";
6
+ export { IQueueNameConfig, IDeadLetterMessage } from "./common";
@@ -14,6 +14,8 @@ export declare class RabbitMqSubscriber {
14
14
  private subscribeToChannel;
15
15
  protected getMessageObject<T>(message: Message): T;
16
16
  protected getChannelSetup(channel: Channel, queueConfig: IQueueNameConfig): Promise<string>;
17
- protected getQueueSettings(): Options.AssertQueue;
17
+ protected getQueueSettings(args?: {
18
+ [key: string]: any;
19
+ }): Options.AssertQueue;
18
20
  protected getDLSettings(): Options.AssertQueue;
19
21
  }
@@ -51,8 +51,14 @@ class RabbitMqSubscriber {
51
51
  }
52
52
  catch (err) {
53
53
  this.logger.error(err, "message processing failed from queue '%j' (%j)", queueConfig, msg);
54
- channel.nack(message, false, false);
55
- throw err;
54
+ // channel.nack(message, false, false);
55
+ channel.publish(queueConfig.dlx, '', Buffer.from(JSON.stringify({
56
+ data: msg,
57
+ error: {
58
+ message: err.message,
59
+ },
60
+ })));
61
+ channel.ack(message);
56
62
  }
57
63
  }));
58
64
  this.logger.trace("subscribed to queue '%s' (%s)", queueConfig.name, opts.consumerTag);
@@ -69,15 +75,16 @@ class RabbitMqSubscriber {
69
75
  getChannelSetup(channel, queueConfig) {
70
76
  return __awaiter(this, void 0, void 0, function* () {
71
77
  yield channel.assertExchange(queueConfig.dlx, "fanout", this.getDLSettings());
72
- let result = yield channel.assertQueue(queueConfig.strictName ? queueConfig.name : queueConfig.dlq, this.getQueueSettings());
78
+ let result = yield channel.assertQueue(queueConfig.strictName ? queueConfig.name : queueConfig.dlq, this.getQueueSettings(queueConfig.arguments));
73
79
  yield channel.bindQueue(result.queue, queueConfig.dlx, "");
74
80
  return result.queue;
75
81
  });
76
82
  }
77
- getQueueSettings() {
83
+ getQueueSettings(args) {
78
84
  return {
79
85
  exclusive: false,
80
86
  autoDelete: true,
87
+ arguments: args,
81
88
  };
82
89
  }
83
90
  getDLSettings() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rxdi/rabbitmq-pubsub",
3
- "version": "0.7.225",
3
+ "version": "0.7.227",
4
4
  "description": "A graphql-subscriptions PubSub Engine using RabbitMQ",
5
5
  "main": "dist/index.js",
6
6
  "repository": {