Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public static async buildQueueConnection(option: NestRabbitTasksQueueOptions, logger: Logger): Promise {
console.log(option.amqpOptions);
const connection = new Haredo({ connection: option.amqpOptions.connectionUrl });
if (option.globalOptions.immutableInfrastructure) {
const channel = await connection.connectionManager.getChannel();
try {
await channel.checkQueue(option.entity.queueName);
} catch (err) {
if (err.code === 404) {
const msg = `You have activated "globalOptions.immutableInfrastructure".
This prevents nest-rabbit-tasks to create non-existent queue.
The queue ${option.entity.queueName} does not exist.
Please create it in RabbitMQ interface.`;
logger.error(msg);
return null;
}
throw err;
}
public onModuleInit() {
setLoggers({
error: this.logger.error.bind(this.logger),
info: this.logger.log.bind(this.logger),
debug: this.logger.debug.bind(this.logger),
});
this.bindMessageFromQueueToMessageHandlerInWorker();
}