是否应该创建一个单一的Azure Web作业(NODEJS)? [英] Should create a single azure web job (NODEJS)?

查看:33
本文介绍了是否应该创建一个单一的Azure Web作业(NODEJS)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建一个运行2个进程(可能更多)的webjob.一直如此.

I need to create a webjob that runs 2 processes (maybe more). All the time.

过程1(连续)

  1. 从队列中获取消息
  2. 对于每条消息,连接到db并更新一个值.
  3. 重复1

过程2(计划-每天清晨)

Process 2 (schedule - every day early in the morning)

  1. 转到数据库并移动记录tmp表
  2. 通过HTTP发送每条记录
  3. 如果无法发送记录,请全天重试.
  4. 如果所有记录都已发送,明天再运行

根据2个流程(应该更多),我可以为所有流程创建一个Web作业吗?还是应该为每个流程创建一个作业?

According to the 2 processes (should be more), Can I create one single web job for all processes ? or should I create a single job for each process?

我在考虑这种实现方式,但我不知道它的准确性如何.

I was thinking about this implementation, but I don't know how accurate it is.

crojobs :1

类型:连续

while(true){
  process1();
  process2();
}


async function process1() {
   // do staff
}

async function process2() {
   // do staff
   // node-cron lib schedule: (every early morning day)
}

推荐答案

根据2个流程(应该更多),我可以为所有流程创建一个Web作业吗?还是应该为每个流程创建一个作业?

According to the 2 processes (should be more), Can I create one single web job for all processes ? or should I create a single job for each process?

简而言之,您需要为每个流程创建一个作业.

当您以连续或计划方式运行Web作业时,Web作业类型适用于其中的所有Web作业.因此,您不能创建一个具有连续性和计划性过程的单个Web作业.有关更多详细信息,您可以参考此文章.

When you run webjob with continuous or schedule, the webjob type is work for all the webjob in it. So you can not create one single webjob which both have continuous and schedule process. For more details, you could refer to this article.

这篇关于是否应该创建一个单一的Azure Web作业(NODEJS)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆