Reconexiones automaticas si se cae rabbitmq
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { RabbitMQEventBus, RMQConnectionParams } from "#shared/infrastructure/RabbitMQEventBus"
|
||||
import { Channel } from "amqp-connection-manager"
|
||||
import { env } from "./env"
|
||||
|
||||
const rmqUser = env.RABBITMQ_USER
|
||||
@@ -18,14 +19,11 @@ export const rmqConnOptions = <RMQConnectionParams>{
|
||||
}
|
||||
|
||||
export const rabbitmqEventBus = new RabbitMQEventBus({
|
||||
connectionParams: rmqConnOptions
|
||||
connectionParams: rmqConnOptions,
|
||||
buildStructure: buildQueues
|
||||
})
|
||||
|
||||
export async function startRMQClient() {
|
||||
await rabbitmqEventBus.connect()
|
||||
const channel = rabbitmqEventBus.channel
|
||||
// Bindings especificos, deberia meterlos en la clase
|
||||
|
||||
function buildQueues(channel: Channel) {
|
||||
channel?.assertQueue("sim.objenious")
|
||||
.then(e => {
|
||||
console.log("[o] Creada la cola " + e.queue)
|
||||
@@ -57,6 +55,9 @@ export async function startRMQClient() {
|
||||
.catch(e => {
|
||||
console.error(e)
|
||||
})
|
||||
}
|
||||
|
||||
export async function startRMQClient() {
|
||||
await rabbitmqEventBus.connect()
|
||||
return rabbitmqEventBus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user