diff --git a/src/services/rabbitmq.ts b/src/services/rabbitmq.ts index ecd30f66..54f82885 100644 --- a/src/services/rabbitmq.ts +++ b/src/services/rabbitmq.ts @@ -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 { @@ -75,18 +76,26 @@ async function handler(msg: amqp.ConsumeMessage): Promise { 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( {