Continuous WebJobs and CancellationToken

I don’t get mechanics for cancellation tokens and web jobs.

I know what I can use Microsoft.Azure.WebJobs.WebJobsShutdownWatcher().Tokento get a token and respond to token.IsCancellationRequested, for example, when updating WebJobs.

Scenario: A continuous job caused by a service bus message. The job calls a method in my data layer. This method performs some updates in different azure sql database tables. This method works for about two minutes.

Now I will transfer the token to the data layer, and there I will do my work until no cancellation is canceled; otherwise I would finish my updates.

Now the questions are:

Does the job owner go to wait for my method to complete and then stop?

Should I set the value of "stopping_wait_time" to a value (what is the default?) High enough to make sure my work is completed correctly?

If a new message is written to the service bus queue, does this message start a new job even though a pending reject is expected?

Thanks for any clarification!

+4
source share
1 answer

No, the WebJob runtime does not wait for your method to complete. The cancellation token, which you can get with WebJobShutdownWatcher, allows you to receive notifications that a website is stopping. This allows only a little time for your code to work fine.

webjobs 5 , , "stopping_wait_time", .

, , - , , . , .

webjobs : https://github.com/projectkudu/kudu/wiki/Web-Jobs

, ,

+4

Source: https://habr.com/ru/post/1622211/


All Articles