test rabbit
This commit is contained in:
parent
6f1e2339f5
commit
e47d3a88ef
1 changed files with 11 additions and 8 deletions
|
|
@ -24,10 +24,12 @@ export async function init() {
|
|||
const channel = await connection.createChannel(); //----> (1.4) create Channel
|
||||
|
||||
console.log(channel ? "[AMQ] Create channel success" : "[AMQ] Create channel failed");
|
||||
|
||||
channel.assertQueue(queue, { durable: true }); //----> (1.5) assert queue and set durable (if "true" save to disk on RabbitMQ)
|
||||
channel.assertQueue(queue_org, { durable: true });
|
||||
channel.prefetch(1);
|
||||
|
||||
await Promise.all([
|
||||
channel.assertQueue(queue, { durable: true }), //----> (1.5) assert queue and set durable (if "true" save to disk on RabbitMQ)
|
||||
channel.assertQueue(queue_org, { durable: true }),
|
||||
channel.prefetch(1)
|
||||
]);
|
||||
|
||||
sendToQueue = (payload: any, persistent = true) => {
|
||||
//----> (2) sendQueue To RabbitMQ and set persistent (if "true" redo the failed queue when server run again)
|
||||
|
|
@ -41,10 +43,11 @@ export async function init() {
|
|||
};
|
||||
|
||||
console.log("[AMQ] Listening for message...");
|
||||
|
||||
await createConsumer(queue, channel, handler); //----> (3) Process Consumer
|
||||
await createConsumer(queue_org, channel, handler_org);
|
||||
// createConsumer(queue2, channel, handler2);
|
||||
await Promise.all([
|
||||
createConsumer(queue, channel, handler), //----> (3) Process Consumer
|
||||
createConsumer(queue_org, channel, handler_org)
|
||||
// createConsumer(queue2, channel, handler2);
|
||||
]);
|
||||
}
|
||||
|
||||
let retries = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue