Router intermedio para las ops de objenious
This commit is contained in:
@@ -27,10 +27,6 @@ export class RabbitMQEventBus implements EventBus {
|
||||
async consume(queue: string, callback: (msg: ConsumeMessage | null) => void) {
|
||||
// Comproaciones antes de escuchar
|
||||
if (this.channel == undefined) throw new Error("[RMQ] Canal no iniciallizado");
|
||||
|
||||
// El binding (cola -> [routingkey] -> exchange) lo hago por configuracion. Meter colas a demanda?
|
||||
//await this.channel.prefetch(1)
|
||||
|
||||
await this.channel.consume(queue, callback)
|
||||
}
|
||||
|
||||
@@ -55,7 +51,7 @@ export class RabbitMQEventBus implements EventBus {
|
||||
try {
|
||||
this.connection = await this.createConnection();
|
||||
if (this.connection == undefined) throw new Error("[RMQ] Error crecreando la conexion")
|
||||
this.channel = await this.createConfirmChannel()
|
||||
this.channel = await this.createChannel()
|
||||
this.channel.on("close", () => {
|
||||
console.log("[RMQ] Canal desconectado")
|
||||
setTimeout(async () => {
|
||||
@@ -116,14 +112,14 @@ export class RabbitMQEventBus implements EventBus {
|
||||
console.log(`[RMQ] Reintentando conexion`)
|
||||
});
|
||||
|
||||
connection.on("disconnect", (err) => {
|
||||
console.error(`[RMQ] Servidor Rabbitmq desconectado, reintentando ...`)
|
||||
connection.on("disconnect", (err: unknown) => {
|
||||
console.error(`[RMQ] Servidor Rabbitmq desconectado, reintentando ... :: ${err}`)
|
||||
})
|
||||
|
||||
return connection;
|
||||
}
|
||||
|
||||
protected async createConfirmChannel() {
|
||||
protected async createChannel() {
|
||||
if (this.connection == undefined) throw new Error("[RMQ] Intentando crear un canal sin una conexion")
|
||||
const channel = this.connection.createChannel({
|
||||
json: true,
|
||||
|
||||
Reference in New Issue
Block a user