0

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

Process 1 (Continuous)

  1. Get messages from the queue
  2. for each message connect to db and update a value.
  3. repeat 1

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

  1. Go to db and move records a tmp table
  2. Send each record vía HTTP
  3. if a record cant sent, retry for all day.
  4. if all records were sent, run again tomorrow

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

Type: Continuous

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


async function process1() {
   // do staff
}

async function process2() {
   // do staff
   // node-cron lib schedule: (every early morning day)
}
makitocode
  • 938
  • 1
  • 16
  • 40
  • Storage Queue documentation is fairly thorough, and goes into detail about how message-reads work (including invisibility timeout, adusting timeout, what happens if you try deleting a message after the invisibility period expires...). There are also several related questions & answers here (including [this one](https://stackoverflow.com/a/10922271/272109) that I wrote several years ago) that give answers related to some of your questions. That said: what you're asking here is fairly broad (and contains multiple questions, some on webjobs, some on queues), plus asking opinions on choices. – David Makogon Apr 22 '20 at 16:22
  • @DavidMakogon thnks. you're ritgh. I edited the question – makitocode Apr 22 '20 at 17:48
  • Any reason to use webjobs as opposed to Azure Functions? They can both watch/be triggered by a queue and run on a schedule, without needing to be tied to an app service. – valverij Apr 22 '20 at 20:43
  • @valverij yeah, azure functions are more expensive than web jobs. also, we have to do other processes using jobs... and.. we have many requests. – makitocode Apr 22 '20 at 21:14
  • Makes sense. That said, I believe you can actually attach an Azure Function to an existing App Service Plan, allowing you to utilize functions while not paying extra on top of your existing app service plan. When choosing the plan, instead of choosing "Consumption," you can choose "App Service Plan" and attach it to an existing plan, if I remember correctly. – valverij Apr 22 '20 at 21:22

1 Answers1

1

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?

In short, you need to create a single job for each process.

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.

Joey Cai
  • 18,968
  • 1
  • 20
  • 30