node.js - 如何处理异步类型任务的ack
问题描述
现在我有一个 RabbitMQ 队列设置,我有几个工作人员正在监听推送到这个队列的事件。
这些事件本质上是字符串 url(例如,“ https://www.youtube.com ”),它将通过 puppeteer 进行处理。
我想知道的是,puppeteer 是异步的,一旦我完成了所有异步的东西,有没有办法让我返回一个 ack。
现在,我认为我的听队列的工作人员正在挂起,因为 ack 没有被解雇。
编辑——下面的代码是我在consume
rabbitmq部分中所称的。因为这是异步的,所以它只是通过了这个操作并立即响应。
(async () => {
const args = {
evaluatePage: (() => ({
title: $('title').text(),
})),
persistCache: true,
cache,
onSuccess: (result => {
console.log('value for result -- ', result.result.title);
}),
};
// we need to first setup the crawler
// then we can start sending information to it
const crawler = await HCCrawler.launch(args);
crawler.queue(urls);
await crawler.onIdle();
await crawler.close();
})();
解决方案
推荐阅读
- android - React native error,canOverrideExistingModule=true
- magento2 - After installing Admin Dashboard stuck at loader
- ssh - ssh weak cipher removal... just benefits or drawbacks as well?
- c# - C# class string used on a another Form
- python - Django-taggit - 如何过滤所有标记的对象,为每个标记重复它们?
- python - Using sklearn with complex values
- python - Matplotlib 在 for 循环中显示空图
- python - Why can't I install these specific requirements?
- javascript - Javascript map() forEach() 方法不能连续工作
- javascript - 关闭一个弹出窗口,打开另一个