direct_reply_to_client.js 549 B

12345678910111213141516171819202122
  1. #!/usr/bin/env node
  2. const amqp = require('../');
  3. const queue = 'rpc_queue';
  4. (async () => {
  5. const connection = await amqp.connect();
  6. const channel = await connection.createChannel();
  7. await channel.consume('amq.rabbitmq.reply-to', async (message) => {
  8. console.log(message.content.toString());
  9. await channel.close();
  10. await connection.close();
  11. }, { noAck: true });
  12. await channel.assertQueue(queue, { durable: false });
  13. channel.sendToQueue(queue, Buffer.from(' [X] ping'), {
  14. replyTo: 'amq.rabbitmq.reply-to',
  15. });
  16. })();