Aug 22, 2024
git clone <repository-url>
cd calf-drop
cd docker-compose
docker-compose up
localhost:9000 to view topics and messages.nest new api-gateway
nest new billing
nest new auth
yarn add @nestjs/microservices kafka.js
CreateOrderRequest class with userId and price properties.ClientsModule from @nestjs/microservices.ClientsModule.register([
{
name: 'BILLING_SERVICE',
transport: Transport.KAFKA,
options: {
client: {
clientId: 'billing',
brokers: ['localhost:9092'],
},
consumer: {
groupId: 'billing-consumer',
},
},
},
]);
order created events.const app = await NestFactory.createMicroservice(AppModule, {
transport: Transport.KAFKA,
options: {
client: {
brokers: ['localhost:9092'],
},
consumer: {
groupId: 'billing-consumer',
},
},
});
order created events in the controller.get user requests from the Billing Service.{
"userId": "12345",
"price": 100
}