@nestjstools/messaging-rabbitmq-extension
Version:
Extension to handle messages and dispatch them over AMQP protocol
30 lines • 927 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.AmqpChannel = void 0;
const messaging_1 = require("@nestjstools/messaging");
const amqp = require("amqplib");
class AmqpChannel extends messaging_1.Channel {
constructor(config) {
super(config);
this.config = config;
}
async init() {
if (this.connection) {
return Promise.resolve();
}
this.connection = undefined;
this.connection = await amqp.connect(this.config.connectionUri);
this.connection.on('close', (err) => {
console.error('AMQP Connection error:', err);
process.exit(0);
});
}
async onChannelDestroy() {
if (this.connection) {
await this.connection.close();
this.connection = undefined;
}
}
}
exports.AmqpChannel = AmqpChannel;
//# sourceMappingURL=amqp.channel.js.map
;