Merge pull request #155 from Tria-plc/feat/payment-microservice

refactor: ( rabbitmq ) temporary remove the rabbitmq
This commit is contained in:
Abubeker Yasin
2026-06-14 18:48:53 +03:00
committed by GitHub

View File

@@ -1,60 +1,67 @@
import { Module } from "@nestjs/common"; import { Module } from "@nestjs/common";
import { HttpModule } from "@nestjs/axios"; import { HttpModule } from "@nestjs/axios";
import { ConfigService } from "@nestjs/config"; // --- TEMPORARILY DISABLED: payment-event RabbitMQ consumer ----------------------------------
import { RabbitMQModule } from "@golevelup/nestjs-rabbitmq"; // The payment broker is currently unreachable (DevOps is fixing it). @golevelup awaits the
import { // @RabbitSubscribe registration during bootstrap, so an unreachable broker hangs the whole API
PAYMENT_EVENTS_DLX, // and it never finishes starting. Disabled so the server boots without the broker.
PAYMENT_EVENTS_EXCHANGE, // TO RE-ENABLE (once the broker is back): uncomment the imports below, the RabbitMQModule entry
PAYMENT_QUEUES, // in `imports`, and PaymentEventsConsumer in `providers`.
PaymentService, // import { ConfigService } from "@nestjs/config";
paymentServiceBindingPattern, // import { RabbitMQModule } from "@golevelup/nestjs-rabbitmq";
} from "@edr/types"; // import {
// PAYMENT_EVENTS_DLX,
// PAYMENT_EVENTS_EXCHANGE,
// PAYMENT_QUEUES,
// PaymentService,
// paymentServiceBindingPattern,
// } from "@edr/types";
import { PaymentsController } from "./payments.controller"; import { PaymentsController } from "./payments.controller";
import { PaymentsService } from "./payments.service"; import { PaymentsService } from "./payments.service";
import { InternalPaymentsController } from "./internal-payments.controller"; import { InternalPaymentsController } from "./internal-payments.controller";
import { PaymentClientService } from "./payment-client.service"; import { PaymentClientService } from "./payment-client.service";
import { PaymentEventsConsumer } from "./payment-events.consumer"; // import { PaymentEventsConsumer } from "./payment-events.consumer";
import { ServiceAuthGuard } from "../../common/guards/service-auth.guard"; import { ServiceAuthGuard } from "../../common/guards/service-auth.guard";
import { SeatsModule } from "../seats/seats.module"; import { SeatsModule } from "../seats/seats.module";
import { TicketsModule } from "../tickets/tickets.module"; import { TicketsModule } from "../tickets/tickets.module";
const PASSENGER_QUEUE = PAYMENT_QUEUES[PaymentService.PASSENGER]; // const PASSENGER_QUEUE = PAYMENT_QUEUES[PaymentService.PASSENGER];
@Module({ @Module({
imports: [ imports: [
SeatsModule, SeatsModule,
TicketsModule, TicketsModule,
HttpModule.register({ timeout: 10_000 }), HttpModule.register({ timeout: 10_000 }),
RabbitMQModule.forRootAsync({ // --- TEMPORARILY DISABLED (broker unreachable) — re-enable with the imports above. -------
inject: [ConfigService], // RabbitMQModule.forRootAsync({
useFactory: (config: ConfigService) => ({ // inject: [ConfigService],
uri: config.get<string>("rabbitmq.url") as string, // useFactory: (config: ConfigService) => ({
exchanges: [ // uri: config.get<string>("rabbitmq.url") as string,
{ // exchanges: [
name: PAYMENT_EVENTS_EXCHANGE, // {
type: "topic", // name: PAYMENT_EVENTS_EXCHANGE,
options: { durable: true }, // type: "topic",
}, // options: { durable: true },
{ name: PAYMENT_EVENTS_DLX, type: "topic", options: { durable: true } }, // },
], // { name: PAYMENT_EVENTS_DLX, type: "topic", options: { durable: true } },
queues: [ // ],
{ // queues: [
name: PASSENGER_QUEUE.dlq, // {
exchange: PAYMENT_EVENTS_DLX, // name: PASSENGER_QUEUE.dlq,
routingKey: paymentServiceBindingPattern(PaymentService.PASSENGER), // exchange: PAYMENT_EVENTS_DLX,
options: { durable: true }, // routingKey: paymentServiceBindingPattern(PaymentService.PASSENGER),
}, // options: { durable: true },
], // },
prefetchCount: config.get<number>("rabbitmq.prefetch") ?? 10, // ],
connectionInitOptions: { wait: false }, // prefetchCount: config.get<number>("rabbitmq.prefetch") ?? 10,
}), // connectionInitOptions: { wait: false },
}), // }),
// }),
], ],
controllers: [PaymentsController, InternalPaymentsController], controllers: [PaymentsController, InternalPaymentsController],
providers: [ providers: [
PaymentsService, PaymentsService,
PaymentClientService, PaymentClientService,
PaymentEventsConsumer, // PaymentEventsConsumer, // TEMPORARILY DISABLED — re-enable with RabbitMQModule above.
ServiceAuthGuard, ServiceAuthGuard,
], ],
}) })