test rabbit
This commit is contained in:
parent
3cb06d9e19
commit
fdbb53e5ae
1 changed files with 9 additions and 0 deletions
|
|
@ -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(
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue