Files
sf-sim/packages/sim-consumidor-objenious/aplication/SimActivation.controller.ts

38 lines
928 B
TypeScript
Raw Normal View History

2026-01-16 11:14:35 +01:00
import { EventBus } from "#shared/domain/EventBus.port";
import { ConsumeMessage } from "amqplib";
export class SimActivationController {
private eventBus: EventBus;
private activationUseCases: any;
constructor(
eventBus: EventBus
) {
this.eventBus = eventBus
// No se si hay un sistema mejor
// convertor en const () => {} para conservar el contexto??
this.activateSim = this.activateSim.bind(this)
}
public activateSim(msg: ConsumeMessage | null) {
if (!this.validateActivationMsg(msg)) {
throw new Error("Error consumiendo el mensaje no es valido")
}
console.log("mensaje procesado", String(msg?.content))
// Caso de uso de activaciones
//
this.eventBus.ack(msg!)
}
/**
* TODO:
* - Loguear motivos de la no validacion
*/
private validateActivationMsg(msg: ConsumeMessage | null) {
if (msg == undefined) return false;
return true;
}
}