Will multiple async business rules maintain their order?

Ethan Dy Tioco1
Tera Expert

Hello community,

I understand that async BR's run on a separate thread, so that the user doesn't have to wait for it to finish before getting control back to their servicenow session.

My question: If I have multiple async business rules for the same table, do they follow the same order of execution as their Order or Priority field? For example, if I have:
1) Async BR 1 (Order 100, Priority 100), which takes a long time to run
2) Async BR 2 (Order 200, Priority 200), which needs to happen after Async BR 1

Will Async BR 2 always run after Async BR 1, or is there a chance that BR 2 will run before BR 1?

 

I'd like to understand more how multiple async BR's behave (e.g., whether they are executed in a single thread or by multiple threads), and how the Order and Priority fields should be used in that case.

4 REPLIES 4

Aman Kumar S
Kilo Patron

Hey,

Below article should help you out

 

async business rule - Order maintained?

 

Do let me know if this helps!

Best Regards
Aman Kumar

Allen Andreas
Administrator
Administrator

Hi,

The order of async merely determines the order in which the async BRs will run. Which means the scheduled job that would run the action(s). The priority then determines how important the job is versus another.

A higher priority value, such as "5,000" will cause the scheduled job from the async business rule to run significantly later than anything else as most scheduled jobs will have a priority of "100".

Since async business rules run when the system gets an opportunity, the order is essentially lost and the priority is then the mechanism used to try and "order" them, to an extent.

The scheduled jobs from async business rules get mixed in with other system scheduled jobs.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Hi @Ethan Dy Tioco 

Thanks for marking my reply as Helpful.

If it ends up guiding you Correctly, please also mark that reply as Correct.

Thanks and take care! 🙂


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Hitoshi Ozawa
Giga Sage
Giga Sage

Hi Ethan,

Simply put, no.

If BR1 will take a long time to run, BR2 may execute and finish before BR1 finishes. If order is important, put the tasks into one scheduled job.

Order and priority may affect when the business rule is executed but it won't guarantee the order when they are completed.

Business rules are executed in multiple threads. Setting to number of thread to 1 will impact overall performance of an instance.

Order field specifies the execution order. Since BR are executed multi-thread, this doesn't imply the order when they will finish execution.

In async business rule, order will be be the order the rule is put into the queue. Priority will determine the order tasks in the queue will begin execution. Priority also won't guarantee the order when the tasks will finish execution.

Following page is about MID Server queues but explains about priority.

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0743566

Following page contains information on execution order of scripts.

https://docs.servicenow.com/bundle/sandiego-application-development/page/script/general-scripting/re...