Answer the question
In order to leave comments, you need to log in
Is it necessary to close the connection in rabbitmq?
Just started to get acquainted with rabbitmq, looked at examples from off site
Finally close the connection and exit
setTimeout(function() {
connection.close();
process.exit(0)
}, 500);
const express = require('express');
const app = express();
const amqp = require('amqplib/callback_api');
amqp.connect('amqp://localhost', function(error0, connection) {
if (error0) {
throw error0;
}
connection.createChannel(function(error1, channel) {
if (error1) {
throw error1;
}
channel.assertQueue('ses', {
durable: false
});
app.get('/serv1',async (req, res) => {
const data = {
name: 'name',
server: '3009',
}
await channel.sendToQueue("ses", Buffer.from(JSON.stringify(data)))
// res.send(data)
})
app.listen(3009, () => {
console.log('server start')
})
});
});
app.listen(3009, () => {
console.log('server start')
})
then why close it, or am I doing something wrong, help me figure it out!
Answer the question
In order to leave comments, you need to log in
it is not necessary to close them,
Rabbit will close them himself, crashing when exceeded in the default settings,
well, or the newly opened ones will not be lucky: they didn’t fall, but new ones are not created or accepted,
you still need to sort out the concept and concepts of what you are doing, look at the logs, monitor look, look at
the lost messages - and understanding will come
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question