@@ -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 ) ;
0 commit comments