I have a controller setup like so:
@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}
@EventPattern({ cmd: 'SUBSCRIBE a' })
getHello(@Payload() data, @Ctx() context: RedisContext) {
console.log(data);
console.log(context);
//return this.appService.getHello();
}
}
My bootstrap code looks like this:
const app = await NestFactory.createMicroservice<MicroserviceOptions>(
AppModule,
{
transport: Transport.REDIS,
options: {
url: 'redis://localhost:6379',
},
},
);
app.listen(() => console.log('listening'));
How do I set I subscribe to a Redis topic? I checked the Redis CLI, and there are currently no subscribers. I want to consume messages from the controller based on a topic name.
I tried everything: @EventPattern({ cmd: 'SUBSCRIBE a' }), @EventPattern({ cmd: 'a' })...
None of the docs mention how to subscribe to a topic.