test rabbit

This commit is contained in:
AdisakKanthawilang 2024-11-15 15:46:50 +07:00
parent 3cb06d9e19
commit fdbb53e5ae

View file

@ -68,6 +68,7 @@ function createConsumer( //----> consumer
},
{ noAck: false },
);
console.log(queue ? "[AMQ] create consumer success" : "[AMQ] create consumer failed");
}
async function handler(msg: amqp.ConsumeMessage): Promise<boolean> {
@ -75,18 +76,26 @@ async function handler(msg: amqp.ConsumeMessage): Promise<boolean> {
const repo = AppDataSource.getRepository(Command);
const { data, token, user } = JSON.parse(msg.content.toString());
console.log(repo ? "[AMQ] have repo" : "[AMQ] don't have repo");
const { id, status, lastUpdateUserId, lastUpdateFullName, lastUpdatedAt } = data;
console.log(data ? "[AMQ] have data" : "[AMQ] don't have data");
const command = await repo.findOne({
where: { id: id },
relations: ["commandType", "commandRecives"],
});
console.log(command ? "[AMQ] have command" : "[AMQ] don't have command");
if (!command) return true;
const path = commandTypePath(command.commandType.code);
if (path == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ");
console.log(path ? "[AMQ] have path" : "[AMQ] don't have path");
return await new CallAPI()
.PostData(
{