amqp nodejs connect on setup api or on route

拟墨画扇 提交于 2021-01-29 07:00:41

问题


Hello i have doubts about amqp lib nodejs

about the connection, should i create the connection when uploading my api? Or just at the end point when requested?

like this:

import express from 'express';
import {connect} from 'amqplib'

connect(this.rabbitUrl), 10, 1000)
const app = express();
app.get('/', (req, res) => {
  return res.send('service A');
});
app.listen(3001, () => {
  console.log(`⚡️ Service A on port 3001`);
});

I have another question: I have 10 requests for 10 different clients, will a connection be made for each client? or is it just a connection to rabbitmq for all requests

来源:https://stackoverflow.com/questions/63813890/amqp-nodejs-connect-on-setup-api-or-on-route

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!