Hexagonal, mejora del cliente RMQ y tipos de eventos

This commit is contained in:
2026-01-13 15:41:59 +01:00
parent a6abc24e5f
commit d2db2062b0
20 changed files with 517 additions and 100 deletions

View File

@@ -0,0 +1,50 @@
import { env } from "#config/env"
import { SimEvents } from "#shared/domain/SimEvents"
import { RabbitMQEventBus, RMQConnectionParams } from "#shared/infrastructure/RabbitMQEventBus"
const rmqUser = env.RABBITMQ_USER
const rmqPass = env.RABBITMQ_PASSWORD
const rmqHost = env.RABBITMQ_HOST
const rmqPort = Number(env.RABBITMQ_PORT)
const rmqSecure = false
const rmqVhost = env.RABBITMQ_VHOST
async function test() {
const connOptions = <RMQConnectionParams>{
username: rmqUser,
password: rmqPass,
vhost: rmqVhost,
hostname: rmqHost,
port: rmqPort,
secure: rmqSecure,
}
const event = <SimEvents.activation>{
key: "sim.activation",
payload: {
iccid: "1234"
},
options: {
}
}
const rmqCli = new RabbitMQEventBus({
connectionParams: connOptions
})
await rmqCli.connect()
console.log("publicando", event)
rmqCli.publish([event])
.then(e => {
console.log("Mensaje publicado", e)
})
.catch(err => console.error)
}
test()
export default {}