diff --git a/backend/services/authorization-service/src/app.module.ts b/backend/services/authorization-service/src/app.module.ts index 62e678c6..b707d420 100644 --- a/backend/services/authorization-service/src/app.module.ts +++ b/backend/services/authorization-service/src/app.module.ts @@ -19,6 +19,7 @@ import { } from '@/infrastructure/persistence/repositories/monthly-assessment.repository.impl' import { RedisModule } from '@/infrastructure/redis/redis.module' import { KafkaModule } from '@/infrastructure/kafka/kafka.module' +import { EventConsumerController } from '@/infrastructure/kafka/event-consumer.controller' // Application import { AuthorizationApplicationService, REFERRAL_REPOSITORY, TEAM_STATISTICS_REPOSITORY } from '@/application/services' @@ -69,7 +70,7 @@ const MockTeamStatisticsRepository = { RedisModule, KafkaModule, ], - controllers: [AuthorizationController, AdminAuthorizationController, HealthController], + controllers: [AuthorizationController, AdminAuthorizationController, HealthController, EventConsumerController], providers: [ // Prisma PrismaService, diff --git a/backend/services/authorization-service/src/infrastructure/kafka/kafka.module.ts b/backend/services/authorization-service/src/infrastructure/kafka/kafka.module.ts index 6fe81577..620d3d16 100644 --- a/backend/services/authorization-service/src/infrastructure/kafka/kafka.module.ts +++ b/backend/services/authorization-service/src/infrastructure/kafka/kafka.module.ts @@ -1,11 +1,33 @@ import { Module, Global } from '@nestjs/common' +import { ConfigModule, ConfigService } from '@nestjs/config' +import { ClientsModule, Transport } from '@nestjs/microservices' import { EventPublisherService } from './event-publisher.service' -import { EventConsumerController } from './event-consumer.controller' +import { EventAckPublisher } from './event-ack.publisher' @Global() @Module({ - controllers: [EventConsumerController], - providers: [EventPublisherService], - exports: [EventPublisherService], + imports: [ + ClientsModule.registerAsync([ + { + name: 'KAFKA_SERVICE', + imports: [ConfigModule], + useFactory: (configService: ConfigService) => ({ + transport: Transport.KAFKA, + options: { + client: { + clientId: configService.get('KAFKA_CLIENT_ID', 'authorization-service'), + brokers: configService.get('KAFKA_BROKERS', 'localhost:9092').split(','), + }, + consumer: { + groupId: configService.get('KAFKA_GROUP_ID', 'authorization-service-group'), + }, + }, + }), + inject: [ConfigService], + }, + ]), + ], + providers: [EventPublisherService, EventAckPublisher], + exports: [EventPublisherService, EventAckPublisher, ClientsModule], }) export class KafkaModule {}