Created
July 7, 2020 18:42
-
-
Save mrsid96/a7c1f28f80fa5cbede86b493229c6cb2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let workOnChannel = async (channel) => { | |
// ... | |
//Consumer listening to the queue, which was ealier created and bind with exchange | |
let { consumerTag } = await channel.consume(queue, function (msg) { | |
if (msg.content) { | |
let dataReceive = JSON.parse(msg.content.toString()); | |
console.log(`[✓] Incomming message ${JSON.stringify(dataReceive)}`); | |
} | |
}, { | |
noAck: true | |
}); | |
//Publisher pushing messages to the 'exchange' which was earlier defined | |
//Dummy data block | |
let data = { | |
message: "This is a sample message", | |
action: "nothing" | |
} | |
channel.publish(exchange, '', Buffer.from(JSON.stringify(data))); | |
// channel.sendToQueue(sessionId, Buffer.from(JSON.stringify(data))); | |
console.log(`[!] Data Pushed to ${exchange}`) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment