@rxdi/graphql-pubsub 0.7.227 → 0.7.229

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 (2) hide show
  1. package/README.md +46 -38
  2. package/package.json +6 -6
package/README.md CHANGED
@@ -92,48 +92,56 @@ GraphQLPubSubModule.forRoot({
92
92
  ##### Complex example of dead letter queue
93
93
 
94
94
  ```typescript
95
- import { AMQPSubscribe, PubSubService } from '@rxdi/graphql-pubsub';
95
+ import { AMQPSubscribe, PubSubService, IDeadLetterMessage } from '@rxdi/graphql-pubsub';
96
96
  import { Injectable } from '@rxdi/core';
97
97
 
98
+ export enum ProjectQueues {
99
+ DELETE_PROJECT_QUEUE = 'delete-project-queue-proba',
100
+ }
101
+
98
102
  @Injectable()
99
- class MyClass {
103
+ export class ProjectDeleteWorker {
100
104
  constructor(private pubsub: PubSubService) {}
101
- OnInit() {
102
- setInterval(() => {
103
- this.pubsub.publish('my-queue', { test: 'aaa' });
104
- console.log('message-send-to-queue');
105
- }, 2000);
106
- }
107
-
108
- @AMQPSubscribe({
109
- queue: 'my-queue',
110
- config: {
111
- prefetch: 1,
112
- globalPrefetch: true,
113
- strictName: true,
114
- arguments: {
115
- 'x-dead-letter-exchange': 'my-queue.DLQ',
116
- },
117
- },
118
- })
119
- first(message) {
120
- console.log('Message received from queue', message);
121
- throw new Error('AAA');
122
- // We throw an error here so we can simulate error job which will automatically send message to dead letter queue
123
- }
124
-
125
- @AMQPSubscribe({
126
- queue: 'my-queue-dlq',
127
- config: {
128
- prefetch: 1,
129
- globalPrefetch: true,
130
- strictName: true,
131
- dlx: 'my-queue.DLQ',
132
- },
133
- })
134
- second(message) {
135
- console.log('Dead Letter Queue', message);
136
- }
105
+
106
+ OnInit() {
107
+ setInterval(() => {
108
+ this.pubsub.publish(ProjectQueues.DELETE_PROJECT_QUEUE, {
109
+ projectId: '69443829a33bcd8655e31b17',
110
+ });
111
+ console.log('message-send-to-queue');
112
+ }, 2000);
113
+ }
114
+
115
+ @AMQPSubscribe({
116
+ queue: ProjectQueues.DELETE_PROJECT_QUEUE,
117
+ config: {
118
+ prefetch: 1,
119
+ globalPrefetch: true,
120
+ strictName: true,
121
+ arguments: {
122
+ 'x-dead-letter-exchange': `${ProjectQueues.DELETE_PROJECT_QUEUE}.DLQ`,
123
+ },
124
+ },
125
+ })
126
+ deleteProjectQueue(message) {
127
+ console.log(message);
128
+ throw new Error('something-went-wrong');
129
+ }
130
+
131
+ @AMQPSubscribe({
132
+ queue: `${ProjectQueues.DELETE_PROJECT_QUEUE}-dlq`,
133
+ config: {
134
+ prefetch: 20,
135
+ globalPrefetch: true,
136
+ strictName: true,
137
+ exchange: `${ProjectQueues.DELETE_PROJECT_QUEUE}.DLQ`,
138
+ },
139
+ })
140
+ deleteProjectDeadLetterQueue(message: IDeadLetterMessage<{ test: string }>) {
141
+ console.log('DLQ', message.data, message.error.message);
142
+ // Save to Database as audit log
143
+ }
137
144
  }
145
+
138
146
  ```
139
147
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rxdi/graphql-pubsub",
3
- "version": "0.7.227",
3
+ "version": "0.7.229",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/rxdi/graphql-pubsub"
@@ -30,14 +30,14 @@
30
30
  },
31
31
  "homepage": "https://github.com/rxdi/graphql-pubsub#readme",
32
32
  "dependencies": {
33
- "@rxdi/graphql-rabbitmq-subscriptions": "^0.7.226",
34
- "@rxdi/rabbitmq-pubsub": "^0.7.226",
33
+ "@rxdi/graphql-rabbitmq-subscriptions": "^0.7.228",
34
+ "@rxdi/rabbitmq-pubsub": "^0.7.228",
35
35
  "subscriptions-transport-ws": "^0.9.19"
36
36
  },
37
37
  "devDependencies": {
38
- "@rxdi/core": "^0.7.226",
39
- "@rxdi/graphql": "^0.7.226",
40
- "@rxdi/hapi": "^0.7.226",
38
+ "@rxdi/core": "^0.7.228",
39
+ "@rxdi/graphql": "^0.7.228",
40
+ "@rxdi/hapi": "^0.7.228",
41
41
  "@types/graphql": "^14.5.0",
42
42
  "@types/hapi": "^18.0.4",
43
43
  "@types/jest": "^24.0.22",