inceptum
Version:
hipages take on the foundational library for enterprise-grade apps written in NodeJS
35 lines • 966 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const amqplib_1 = require("amqplib");
class RabbitmqClient {
constructor(clientConfig, name) {
clientConfig.protocol = clientConfig.protocol || 'amqp';
this.clientConfig = clientConfig;
this.name = name;
}
async init() {
await this.connect();
await this.createChannel();
}
/**
* Connect to RabbitMQ broker
*/
async connect() {
this.connection = await amqplib_1.connect(this.clientConfig);
}
async createChannel() {
this.channel = await this.connection.createChannel();
}
async close() {
await this.closeChannel();
await this.closeConnection();
}
async closeChannel() {
this.channel.close();
}
async closeConnection() {
this.connection.close();
}
}
exports.RabbitmqClient = RabbitmqClient;
//# sourceMappingURL=RabbitmqClient.js.map