20 lines
550 B
TypeScript
20 lines
550 B
TypeScript
|
import { MicroserviceOptions, Transport } from '@nestjs/microservices';
|
||
|
import { NestFactory } from '@nestjs/core';
|
||
|
import { AppModule } from './app.module';
|
||
|
|
||
|
async function bootstrap() {
|
||
|
const app = await NestFactory.createMicroservice<MicroserviceOptions>(
|
||
|
AppModule,
|
||
|
{
|
||
|
transport: Transport.NATS,
|
||
|
options: {
|
||
|
servers: ['nats://localhost:4222'], // 可以指定链接到多个nats的消息队列
|
||
|
maxReconnectAttempts: 5,
|
||
|
reconnectTimeWait: 1000,
|
||
|
},
|
||
|
},
|
||
|
);
|
||
|
await app.listen();
|
||
|
}
|
||
|
bootstrap();
|