Skip to content

Commit 74b8cd5

Browse files
committed
Fix rematch bug and log queue states
1 parent 64d4c12 commit 74b8cd5

File tree

2 files changed

+24
-11
lines changed

2 files changed

+24
-11
lines changed

backend/matching-service/src/config/rabbitmq.ts

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,25 @@ const setUpConsumer = async (queueName: string) => {
5454

5555
consumerChannel.consume(queueName, (msg) => {
5656
if (msg !== null) {
57-
const matchRequestItem = JSON.parse(msg.content.toString());
57+
const matchRequestItem = JSON.parse(
58+
msg.content.toString()
59+
) as MatchRequestItem;
5860
const waitingList = getWaitingList(queueName);
5961
const [complexity, category] = deconstructQueueName(queueName);
62+
console.log(
63+
`Consumed from ${queueName}: ${JSON.stringify(matchRequestItem)}`
64+
);
65+
console.log(
66+
`Waiting list before matching: ${JSON.stringify([
67+
...waitingList.entries(),
68+
])}`
69+
);
6070
matchUsers(matchRequestItem, waitingList, complexity, category);
71+
console.log(
72+
`Waiting list after matching: ${JSON.stringify([
73+
...waitingList.entries(),
74+
])}`
75+
);
6176
consumerChannel.ack(msg);
6277
}
6378
});
@@ -70,13 +85,11 @@ const routeToQueue = async (
7085
try {
7186
const queueName = constructQueueName(criterias);
7287
const senderChannel = await mrConnection.createChannel();
73-
senderChannel.sendToQueue(
74-
queueName,
75-
Buffer.from(JSON.stringify(requestItem)),
76-
{
77-
persistent: true,
78-
}
79-
);
88+
const msg = JSON.stringify(requestItem);
89+
senderChannel.sendToQueue(queueName, Buffer.from(msg), {
90+
persistent: true,
91+
});
92+
console.log(`Sent to ${queueName}: ${msg}`);
8093
return true;
8194
} catch (error) {
8295
console.log(error);

frontend/src/contexts/MatchContext.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -409,9 +409,9 @@ const MatchProvider: React.FC<{ children?: React.ReactNode }> = (props) => {
409409

410410
const rematchRequest = {
411411
user: matchUser,
412-
complexities: matchCriteria.complexity,
413-
categories: matchCriteria.category,
414-
languages: matchCriteria.language,
412+
complexity: matchCriteria.complexity,
413+
category: matchCriteria.category,
414+
language: matchCriteria.language,
415415
timeout: matchCriteria.timeout,
416416
};
417417
matchSocket.emit(

0 commit comments

Comments
 (0)