Answer the question
In order to leave comments, you need to log in
MicroMQ and RabbitMQ request queue inside a service?
I have a "Browser" service that parses a page. You send him a url, he returns information about what kind of page it is, title, description, and so on.
The problem is when the service crashes. Another microservice continues to send tasks to it even at the moment when the Browser service is restarted. He gets a bunch of identical tasks and tightly hangs the system.
How to organize a queue inside a microservice so that it becomes single threaded, for example? And he processed 1 task, and the rest simply lay in the queue.
service
const app = new MicroMQ({
name: serviceName, //browser - serviceName
rabbit: {
url: rabbitHost,
}
});
app.post('/tools/urls_info', async function (request, response) {
let { urls } = request.body;
let urls_info = [];
for(const url of urls){
let info = await browser(url);
urls_info.push(info)
}
response.json({result: true, array: urls_info});
});
app.start()
let {responce} = await app.ask('browser', {
path: '/tools/urls_info',
method: 'post',
body: {
urls: urls_array
}
});
Answer the question
In order to leave comments, you need to log in
I would like to understand what it means
tightly hangs the system.in the context of microservices? And why is this a problem?
He gets a bunch of the same tasksWhy is it necessary to process the same URLs repeatedly?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question