@@ -54,10 +54,25 @@ const setUpConsumer = async (queueName: string) => {
54
54
55
55
consumerChannel . consume ( queueName , ( msg ) => {
56
56
if ( msg !== null ) {
57
- const matchRequestItem = JSON . parse ( msg . content . toString ( ) ) ;
57
+ const matchRequestItem = JSON . parse (
58
+ msg . content . toString ( )
59
+ ) as MatchRequestItem ;
58
60
const waitingList = getWaitingList ( queueName ) ;
59
61
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
+ ) ;
60
70
matchUsers ( matchRequestItem , waitingList , complexity , category ) ;
71
+ console . log (
72
+ `Waiting list after matching: ${ JSON . stringify ( [
73
+ ...waitingList . entries ( ) ,
74
+ ] ) } `
75
+ ) ;
61
76
consumerChannel . ack ( msg ) ;
62
77
}
63
78
} ) ;
@@ -70,13 +85,11 @@ const routeToQueue = async (
70
85
try {
71
86
const queueName = constructQueueName ( criterias ) ;
72
87
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 } ` ) ;
80
93
return true ;
81
94
} catch ( error ) {
82
95
console . log ( error ) ;
0 commit comments