Orders con endpoints para monitorizacion

This commit is contained in:
2026-02-25 12:20:52 +01:00
parent c416114c50
commit 02c80cd503
16 changed files with 373 additions and 63 deletions

View File

@@ -107,20 +107,24 @@ export class RabbitMQEventBus implements EventBus {
const exchange = "sim.exchange"
const routingKey = event.key
const content = Buffer.from(JSON.stringify(event))
await this.channel?.publish(exchange, routingKey, content, {
const isPublished = await this.channel?.publish(exchange, routingKey, content, {
headers: {
...event.headers
}
}, (err, ok) => {
if (err == undefined) {
console.log("Evento publicado ", event)
successEvents.push(event)
} else {
console.error("Error publicando", event)
errorEvents.push(event)
}
})
// Hay que revisarlo pero en principio la libreria se encarga que el mensaje se publique
// si o si
successEvents.push(event)
}
return res({
success: successEvents,
error: errorEvents
@@ -168,7 +172,8 @@ export class RabbitMQEventBus implements EventBus {
if (this.connection == undefined) throw new Error("[RMQ] Intentando crear un canal sin una conexion")
const channel = this.connection.createChannel({
setup: async (channel: Channel) => {
confirm: true,
setup: async (channel: ConfirmChannel) => {
// Exchanges comunes a todos
channel.assertExchange("sim.exchange", "topic", { durable: true })
channel.assertExchange("sim.dlx", "topic", { durable: true })
@@ -202,6 +207,6 @@ export class RabbitMQEventBus implements EventBus {
Promise.reject(error);
});
return channel as ChannelWrapper;
return channel;
}
}