Skip to content

Commit

Permalink
feat(microservices-shared-rmq): create RMQ helper lib
Browse files Browse the repository at this point in the history
  • Loading branch information
getlarge committed Dec 13, 2023
1 parent 893452e commit 5b67f6b
Show file tree
Hide file tree
Showing 26 changed files with 134 additions and 269 deletions.
6 changes: 5 additions & 1 deletion apps/expiration/src/app/orders/orders.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
type AmqpOptions,
AmqpClient,
} from '@s1seven/nestjs-tools-amqp-transport';
import { getReplyQueueName } from '@ticketing/microservices/shared/rmq';
import { Services } from '@ticketing/shared/constants';

import { AppConfigService } from '../env';
Expand Down Expand Up @@ -40,7 +41,10 @@ import { OrdersMSController } from './orders-ms.controller';
exclusive: false,
autoDelete: false,
},
replyQueue: `${Services.ORDERS_SERVICE}_REPLY_${Services.EXPIRATION_SERVICE}_QUEUE`,
replyQueue: getReplyQueueName(
Services.ORDERS_SERVICE,
Services.EXPIRATION_SERVICE,
),
replyQueueOptions: {
durable: true,
exclusive: true,
Expand Down
3 changes: 2 additions & 1 deletion apps/orders/src/app/orders/orders.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { OryModule } from '@ticketing/microservices/ory-client';
import { PassportModule } from '@ticketing/microservices/shared/fastify-passport';
import { GlobalErrorFilter } from '@ticketing/microservices/shared/filters';
import { JwtStrategy } from '@ticketing/microservices/shared/guards';
import { getReplyQueueName } from '@ticketing/microservices/shared/rmq';
import { CURRENT_USER_KEY, Services } from '@ticketing/shared/constants';

import { AppConfigService } from '../env';
Expand All @@ -35,7 +36,7 @@ const clientFactory = (
prefetchCount: configService.get('RMQ_PREFETCH_COUNT'),
isGlobalPrefetchCount: false,
queue: `${consumerService}_QUEUE`,
replyQueue: `${consumerService}_REPLY_${Services.TICKETS_SERVICE}_QUEUE`,
replyQueue: getReplyQueueName(consumerService, Services.TICKETS_SERVICE),
queueOptions: {
durable: true,
exclusive: false,
Expand Down
6 changes: 5 additions & 1 deletion apps/orders/test/tickets-ms.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { AmqpClient, AmqpServer } from '@s1seven/nestjs-tools-amqp-transport';
import { loadEnv, validate } from '@ticketing/microservices/shared/env';
import { Patterns } from '@ticketing/microservices/shared/events';
import { GlobalErrorFilter } from '@ticketing/microservices/shared/filters';
import { getReplyQueueName } from '@ticketing/microservices/shared/rmq';
import { Services } from '@ticketing/shared/constants';
import { Model, Types } from 'mongoose';
import { delay, lastValueFrom } from 'rxjs';
Expand Down Expand Up @@ -63,7 +64,10 @@ describe('TicketsMSController (e2e)', () => {
prefetchCount: 1,
isGlobalPrefetchCount: false,
queue: `${Services.ORDERS_SERVICE}_QUEUE`,
replyQueue: `${Services.ORDERS_SERVICE}_REPLY_${Services.TICKETS_SERVICE}_QUEUE`,
replyQueue: getReplyQueueName(
Services.ORDERS_SERVICE,
Services.TICKETS_SERVICE,
),
queueOptions: {
durable: false,
exclusive: false,
Expand Down
6 changes: 5 additions & 1 deletion apps/payments/src/app/payments/payments.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { OryModule } from '@ticketing/microservices/ory-client';
import { PassportModule } from '@ticketing/microservices/shared/fastify-passport';
import { GlobalErrorFilter } from '@ticketing/microservices/shared/filters';
import { JwtStrategy } from '@ticketing/microservices/shared/guards';
import { getReplyQueueName } from '@ticketing/microservices/shared/rmq';
import { CURRENT_USER_KEY, Services } from '@ticketing/shared/constants';
import { updateIfCurrentPlugin } from 'mongoose-update-if-current';

Expand Down Expand Up @@ -61,7 +62,10 @@ const MongooseFeatures = MongooseModule.forFeatureAsync([
prefetchCount: configService.get('RMQ_PREFETCH_COUNT'),
isGlobalPrefetchCount: false,
queue: `${Services.ORDERS_SERVICE}_QUEUE`,
replyQueue: `${Services.ORDERS_SERVICE}_REPLY_${Services.PAYMENTS_SERVICE}_QUEUE`,
replyQueue: getReplyQueueName(
Services.ORDERS_SERVICE,
Services.PAYMENTS_SERVICE,
),
queueOptions: {
durable: true,
exclusive: false,
Expand Down
6 changes: 5 additions & 1 deletion apps/tickets/src/app/tickets/tickets.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { OryModule } from '@ticketing/microservices/ory-client';
import { PassportModule } from '@ticketing/microservices/shared/fastify-passport';
import { GlobalErrorFilter } from '@ticketing/microservices/shared/filters';
import { JwtStrategy } from '@ticketing/microservices/shared/guards';
import { getReplyQueueName } from '@ticketing/microservices/shared/rmq';
import { CURRENT_USER_KEY, Services } from '@ticketing/shared/constants';
import { updateIfCurrentPlugin } from 'mongoose-update-if-current';

Expand Down Expand Up @@ -45,7 +46,10 @@ const OrdersClient = ClientsModule.registerAsync([
prefetchCount: configService.get('RMQ_PREFETCH_COUNT'),
isGlobalPrefetchCount: false,
queue: `${Services.ORDERS_SERVICE}_QUEUE`,
replyQueue: `${Services.ORDERS_SERVICE}_REPLY_${Services.TICKETS_SERVICE}_QUEUE`,
replyQueue: getReplyQueueName(
Services.ORDERS_SERVICE,
Services.TICKETS_SERVICE,
),
queueOptions: {
durable: true,
exclusive: false,
Expand Down
6 changes: 5 additions & 1 deletion apps/tickets/test/orders-ms.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { AmqpClient, AmqpServer } from '@s1seven/nestjs-tools-amqp-transport';
import { loadEnv, validate } from '@ticketing/microservices/shared/env';
import { Patterns } from '@ticketing/microservices/shared/events';
import { GlobalErrorFilter } from '@ticketing/microservices/shared/filters';
import { getReplyQueueName } from '@ticketing/microservices/shared/rmq';
import { Services } from '@ticketing/shared/constants';
import { Types } from 'mongoose';
import { delay, lastValueFrom } from 'rxjs';
Expand Down Expand Up @@ -60,7 +61,10 @@ describe('OrdersMSController (e2e)', () => {
prefetchCount: 1,
isGlobalPrefetchCount: false,
queue: `${Services.TICKETS_SERVICE}_QUEUE`,
replyQueue: `${Services.TICKETS_SERVICE}_REPLY_${Services.TICKETS_SERVICE}_QUEUE`,
replyQueue: getReplyQueueName(
Services.TICKETS_SERVICE,
Services.ORDERS_SERVICE,
),
queueOptions: {
durable: false,
exclusive: false,
Expand Down
3 changes: 0 additions & 3 deletions libs/microservices/shared/nats-streaming/.babelrc

This file was deleted.

7 changes: 0 additions & 7 deletions libs/microservices/shared/nats-streaming/README.md

This file was deleted.

17 changes: 0 additions & 17 deletions libs/microservices/shared/nats-streaming/jest.config.ts

This file was deleted.

26 changes: 0 additions & 26 deletions libs/microservices/shared/nats-streaming/project.json

This file was deleted.

3 changes: 0 additions & 3 deletions libs/microservices/shared/nats-streaming/src/index.ts

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

13 changes: 0 additions & 13 deletions libs/microservices/shared/nats-streaming/tsconfig.json

This file was deleted.

11 changes: 0 additions & 11 deletions libs/microservices/shared/nats-streaming/tsconfig.lib.json

This file was deleted.

7 changes: 7 additions & 0 deletions libs/microservices/shared/rmq/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# microservices-shared-rmq

This library was generated with [Nx](https://nx.dev).

## Running unit tests

Run `nx test microservices-shared-rmq` to execute the unit tests via [Jest](https://jestjs.io).
Loading

0 comments on commit 5b67f6b

Please sign in to comment.