How should I use this within RabbitSubscribe method?
tomtomyoungs opened this issue · comments
@Injectable()
export class MqService {
constructor(
private readonly amqpConnection: AmqpConnection,
) {
this.handleMessage = this.handleMessage.bind(this);
}
public async sendDelayedMessage(data: string, delay: number) {
await this.amqpConnection.publish('delayed_exchange', 'delete_domain', { data }, { headers: { 'x-delay': delay } });
}
@RabbitSubscribe({
exchange: 'delayed_exchange',
routingKey: 'delete_domain',
queue: 'delayed_queue',
})
public async handleMessage(message: { data: string }) {
console.log(this); // ==> {}
}
}
How should I use this within handleMessage?