2026-01-12 13:08:56 +01:00
|
|
|
import { env } from "#config/env"
|
|
|
|
|
import { RabbitConnection } from "#shared/adapters/queues/RabbitMQClient"
|
2026-01-08 13:36:52 +01:00
|
|
|
|
|
|
|
|
const rmqUser = env.RABBITMQ_USER
|
|
|
|
|
const rmqPass = env.RABBITMQ_PASSWORD
|
|
|
|
|
const rmqHost = env.RABBITMQ_HOST
|
|
|
|
|
const rmqPort = Number(env.RABBITMQ_PORT)
|
2026-01-08 17:10:09 +01:00
|
|
|
const rmqSecure = false
|
|
|
|
|
const rmqVhost = env.RABBITMQ_VHOST
|
|
|
|
|
|
|
|
|
|
|
2026-01-12 13:08:56 +01:00
|
|
|
console.log("[Generador] Iniciando")
|
2026-01-08 13:36:52 +01:00
|
|
|
|
2026-01-12 13:08:56 +01:00
|
|
|
async function test() {
|
2026-01-08 17:10:09 +01:00
|
|
|
|
2026-01-12 13:08:56 +01:00
|
|
|
const rbmq = new RabbitConnection({
|
|
|
|
|
username: rmqUser,
|
|
|
|
|
password: rmqPass,
|
|
|
|
|
vhost: String(rmqVhost),
|
|
|
|
|
hostname: rmqHost,
|
|
|
|
|
port: rmqPort,
|
|
|
|
|
secure: rmqSecure
|
|
|
|
|
})
|
2026-01-08 13:36:52 +01:00
|
|
|
|
2026-01-08 17:10:09 +01:00
|
|
|
await rbmq.connect()
|
|
|
|
|
|
2026-01-12 13:08:56 +01:00
|
|
|
console.log("[Generador] enviando --")
|
2026-01-08 17:10:09 +01:00
|
|
|
|
|
|
|
|
rbmq.channel?.sendToQueue("sim.queue", Buffer.from("test"), {},
|
|
|
|
|
function (err, ok) {
|
|
|
|
|
if (err !== null)
|
|
|
|
|
console.warn('Message nacked!');
|
|
|
|
|
else
|
|
|
|
|
console.log('Message acked');
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
|
2026-01-08 13:36:52 +01:00
|
|
|
}
|
|
|
|
|
|
2026-01-08 17:10:09 +01:00
|
|
|
test()
|
|
|
|
|
|
2026-01-08 13:36:52 +01:00
|
|
|
export default {}
|