Understanding System Runtime Context

Hi,

My customer develops multiple applications in a single platform for each region, and had minor confusion as Job Scheduler did not run as expected when they imported an application to the target environment. System Runtime Context is not something that developer should always care as it is auto-managed, but in such case you may have to manually maintain it. In this post, I will explain what System Runtime Context is, and how it works.

1. What is System Runtime Context

When we log in to Pega thru browser, application context is established using the access group of the operator and respective UI and logic are executed. However, for background process (Job Scheduler and Queue Processor) there is no specific user associated and System Runtime Context is used to help these to define which rules to run, in what priority, namely rule resolution. Actually, Pegasystems had introduced a new Requestor Type called “ASYNCPROCESSOR” in Pega 8.1 to take care of this but since Requestor Type rule can reference only a single access group, there was a limitation in multiple applications environments and hence deprecated. In 8.3, System Runtime Context was newly added to replace ASYNCPROCESSOR Requestor Type. In Dev Studio, you can go to the configuration gadget from System > General > System Runtime Context.

2. When System Runtime Context is updated

System Runtime Context adds application at the top line when application rule is saved. It is also removed when application rule is deleted. There are two conditions for this automatic addition or removal to work. One is you must turn on “Include in background processing” checkbox in application rule. This checkbox is checked by default if you use New Application wizard, but if you manually create an application rule from Records explorer, this is not checked. Also, once updated, system restart is not required. It takes effect immediately, and Job Scheduler will be executed based on the updated new context from the next run in real time.

Another condition is to turn off “Disable automatic updates” checkbox. This is off by default, and I recommend the default settings, so system can automatically manage it for you.

3. Where the settings are stored

Information configured in System Runtime Context gadget is stored in a physical table. It is an instance of System-Runtime-Context class, and it is mapped to PR_SYS_RUNTIME_CONTEXT table in a RULES schema. The stack of application is stored as a Page List in Blob and the name of this instance is “Default”. You may wonder, if this is a database record of a concrete class, shouldn’t we include this instance in the R-A-P? No, it is not required because System Runtime Context update is triggered not only when you hit the “Save” button on application rule form, but also when you import the Jar/Zip file to the target environment. You would only need to check if it is updated as you expect after import.

4. How System Runtime Context resolves rules (how rule resolution works)

The order of the applications listed in System Runtime Context is important. Just like application rule refers the order of the ruleset in the ruleset list, System Runtime Context also refers to the order of the application in the list. Applications at the top of the list take higher precedence. This is the straightforward, general rule.

However, it is not always the case - what you see in System Runtime Context gadget may behave differently depending on your application design. In a nutshell, the hierarchy of application (built on other application) is tied together, and trusted more than the gadget. For example, if you have two applications, MyApp and Myco, and MyApp is built on MyCo, then MyApp always takes higher precedence despite the order in the gadget (see 4-1. Example 1 below). On the other hand, if you have applications that have no hierarchy (no built on relations) then order is applied. For example, assuming you create a standalone application Sandbox. If Sandbox is listed at the top above MyApp / MyCo, then Sandbox takes higher precedence over MyApp / MyCo (see 4-2. Example 2 below). Conversely, if Sandbox is listed below MyApp / MyCo, then MyApp / MyCo takes higher precedence over Sandbox. Please see below for the details.

4-1. Example 1: In your system, you have two applications and one is built on top of the other.

  • Application rules in a system

You create MyApp application first and then create MyCo application later. MyApp application is built on top of MyCo application.

  • System Runtime Context gadget (auto-managed)

Since MyCo was created after MyApp, MyCo is added to the top of the list.

  • Actual rule resolution process (precedence)

However, system correctly detects MyApp should take precedence over MyCo and it rearranges it as such, internally.

No Ruleset
1 MyApp:01-01-01
2 MyAppInt:01-01-01
3 MyCo:01-01-01
4 MyCoInt:01-01-01
5 Pega-ProcessCommander:08-06
6

4-2. Example 2: In your system, you have two sets of individual applications.

  • Application rules in a system

You create Sandbox application first. Then you create MyApp / MyCo application later. MyApp application is built on top of MyCo application.

  • System Runtime Context gadget (auto-managed)

Since Sandbox was created first, it is added to the top initially. Then MyApp was created and it comes on top. Finally, MyCo is created and it gets added to the top of the list.

  • Actual rule resolution process (precedence)
No Ruleset
1 MyApp:01-01-01
2 MyAppInt:01-01-01
3 MyCo:01-01-01
4 MyCoInt:01-01-01
5 Sandbox:01-01-01
6 SandboxInt:01-01-01
7 Pega-ProcessCommander:08-06
8

Note: If you create Sandbox at last (or manually drag and drop to place Sandbox on top of the list), system will realize Sandbox is the highest priority. In this case, the rule resolution precedence changes in the order of Sandbox, SandboxInt, MyApp, MyAppInt, MyCo, MyCoInt, Pega-ProcessCommender, and so on.

5. Limitations

Just like other rule type, Job Scheduler is also overridable. If you have a Job Scheduler in two layers with the same name, the only one in a higher precedence is executed, and the one in a lower precedence is not executed. Now, let’s think of application structures as below. You have two “sibling” applications, MyApp1 and MyApp2. Both applications are on top of MyCo. Also, let’s assume System Runtime Context gadget lists applications in the order of MyApp2, MyApp1, MyCo, and PegaRULES. In this case, if you create a JobScheduler “MyJobScheduler” as well as an activity “MyActivity” within all three of applications, which one(s) are executed? Can we run ones in both siblings?

The answer is system runs only the one in MyApp2. This is because MyApp2 and MyApp1 have no built on relations, so whichever comes first takes precedence - in this case, MyApp2. MyCo is overridden and hence ignored. It is not possible to run two Job Schedulers in MyApp1 and MyApp2 in a single system at the same time. This is a limitation of the current System Runtime. Even if you specify Access Group for context (in Job Scheduler rule you can choose either fixed Access Group or System Runtime Context), the result is the same - you can change the activity to run in a specific ruleset that Access Group references but the Job Scheduler that gets picked up is still one. So I would say this is a limitation of Job Scheduler in a sibling application environment.

6. Suggestions

If your application is simple and configured as a single linear stack, you do not have to worry about System Runtime Context as system automatically maintains it. If you have multiple applications that are unrelated to each other including sibling applications, you need to pay careful attention. Personally, I would manually update it regardless of the application designs because auto-managed list is sometimes confusing for other developers even though internal rule resolution is correct. Updating manually does not conflict with automatic updates (automatic updates simply allow addition or removal by the system from next time). Also, if you are exporting some portion of applications to other environment, you should always check if System Runtime Context is okay after import.

7. Bugs

You may not be able to find delete icon in 8.4.x, 8.5.x, and 8.6.x.

This is a bug and already fixed in the patch release (8.4.6, 8.5.4, and 8.6.1). Please apply patch release accordingly. Or if you need an immediate solution, here is a workaround - add pzCanEditSRC privilege for Embed-AppInfo class to your access role (ex. MyApp:SysAdm4).

Hope this helps.

Thanks,

@KenshoTsuchihashi What is the purpose of “Context” setting on Job Scheduler rule if it doesn’t affect anything and always goes with System Runtime Context?

Is it a bug?

@KenshoTsuchihashi

One question w.r.t your example 4.1–> If I have application structure as MyApp2 built on MyApp1, MyApp1 is built on MyCo, and MyCo is built on PegaRules. And in the system run time context is as below

PegaRules

MyCo

MyApp2

MyApp1

In this case as per what you explained Rule resolution will organize rules starting from MyApp1 in reverse order. Is that right?

@MadhusudanS9253

As I wrote in my original post, the hierarchy of application (built on other application) is tied together, and trusted more than the gadget. In your scenario, application rules in your system is sequential and since there is no siblings shown as below, the rule resolution precedence is simply in the order of MyApp2, MyApp2Int, MyApp1, MyApp1Int, MyCo, MyCoInt, Pega-ProcessCommender, regardless of System Runtime Context settings. Hope this clarifies your question.

Thanks,

@KenshoTsuchihashi i was wondering what if myApp2 is build on myApp1, and myApp1 is build on myCo and say myCo has reference to the PegaRules.

  1. do we need to define all the application, or its enough when we add myApp2 on the system context?

  2. what is the use of Roles on the system runtime context, normaly we see that its predefined with PegaRULE:AsyncProcessor?

your response is appreciated.

@KenshoTsuchihashi

Nicely articulated and great insight.

In this situation, the solution would be to give each Job Scheduler a different name, so that they can each execute their own work separately. As presumption is that each job scheduler working on their own application with lil bit different or specific context logic.

@KenshoTsuchihashi How does it work in the scenario where I create new versions of the base application “MyCo” in your example.
Will the SRC be updated automatically to the latest version of Myco ?

Also, Let’s say there are 2 applications App1, App2 each of it is built on same version of MyCo initially.

If we create new version of MyCo application and only update App2 to point to the new version of MyCo, how does the SRC look ?

Does it point to the latest MyCo version ? (in this example, App1 will be on an older version of MyCo, App2 is on latest version of MyCo)

We are on v8.7.4.

@KenshoTsuchihashi I am not clear,why we need to provide access group for the activity even if it will take precedence based on the System Runtime Context? And as you also wrote in your post that (Para 5) “Even if you specify Access Group for context (in Job Scheduler rule you can choose either fixed Access Group or System Runtime Context), the result is the same - you can change the activity to run in a specific ruleset that Access Group references but the Job Scheduler that gets picked up is still one.”

So for which application the activity will execute then?

@KenshoTsuchihashi Another highly informative and valuable article. Thank you !

I have a question here. If there are 2 versions of same application say MyApp 01.01.01 and MyApp 01.01.02

MyApp 01.01.01 → Ruleset MyRS 01-01

MyApp 01.01.02 → Ruleset MyRS 02 -01(Major Skim performed)

There is no Built-on relationship between the 2 Applications.

Now if in the SRC MyApp 01.01.01 is mentioned before MyApp 02.01.01 which Rulesets will be considered by system - MyRS 02-01-xx or MyRS 01-01-xx ?

In our POC we see whenever both the Application versions are in the stack (irrespective of their order) always MyRS 02-01-XX rules are being considered. Wanted your expert opinion on this.

Thanking you in advance.

Saikat Dasgupta

@DmitryK7052

In “Context” field of Job Scheduler, you can choose either “Use System Runtime Context” or “Specify access group”. If you select “Specify access group”, the activity that gets called is rule-resoluted based on the specified access group (System Runtime Context is ignored). For example, if you have two “sibling” applications (MyApp1 and MyApp2), which have no built on relations to each other, and MyApp2 is on top of the order in the System Runtime Context gadget, JobScheduler in MyApp2 ruleset is picked up. In this case, if you want to, you can trigger an activity in MyApp1 from MyApp2 Job Scheduler independently. This field is to set the context of activity, not Job Scheduler.

On the other hand, all Job Schedulers are rule-resolved against the context specified in the System Runtime Context. There is no way to run multiple same named Job Schedulers at the same time. Hope this clarifies your question.

Thanks,

@Amir

In your scenario, application rules in your system is sequential and the rule resolution precedence is simply in the order of MyApp2, MyApp2Int, MyApp1, MyApp1Int, MyCo, MyCoInt, Pega-ProcessCommender.

Now, do we have to list all applications in the System Runtime Context? No, it is not required. However, you should have the highest application (in this case, MyApp2) as below screenshot. No other applications are required.

You may wonder, what if you have only MyApp1 in the System Runtime Context? In that case, system can’t detect MyApp2, which will result in MyApp1, MyApp1Int, MyCo, MyCoInt, Pega-ProcessCommander. Hope this clarifies your question.

Thanks,

Hi @KenshoTsuchihashi,
Thanks for the explanation.
For question #2, I was checking for a scenario where MyApp1 is still built on MyCo:01.01.01
But MyApp2 will be updated to be built on MyCo:01.01.02. Will the SRC still pick latest version of MyCo ?

@KenshoTsuchihashi thanks for the explanation, we have a weird scenario, where the application is correctly listed which says app:01-16 but in the resolved ruleset list, it shows app:01-09 and we have a QP in 01-15-02 version of the ruleset, not sure what is going on. we already had the run in background checkbox on app rule from checked and I tried, saving the SRC, disable enable the automatic updates toggle, nothing worked. Do you have any ideas or suggestions?

@KenshoTsuchihashi

Thanks for detailed explanation.

We have 2 implementation applications (ImpApp1, ImpApp2) both built on FWApp [Application stack will be like ImpApp1 → FWApp and ImpApp2 → FwApp]. Each application has dedicated schema’s. If we create a single job scheduler with SRC at FW layer to fetch data from worktables of Implementation Application by providing work class names dynamically during execution of Job scheduler activity. Does it cause any issue at runtime?

Hi.

@KenshoTsuchihashi Are there Pega internal plannings to remove the SRC + unspecified batch requestors completely or at least improve it to a usable way, as it is currently working against the propagated modul design approach and proper working Pega enterprise platforms?

If not, i would be happy for a personal exchange on this topic, to explain my concerns which have forced me to my above question :slight_smile:

Thanks & regards, Matthias

@KenshoTsuchihashi : Hi , one observation from my end. Today say if you added app MyApp 01.01.01 and add another app MyAppNew 01.01.01 later. Even if you update the MyApp 01.01.01 in later stages, it remains in bottom in the sequence

@Sandeep Katakam we realized that the issue is because of the specific ruleset version listed in one of the ruleset stacks on the top of the applications listed in the SRC.

@pavankumarp6690

  • For question #1:

Say, you have an application MyCo:01.01.01 and it is currently listed in the System Runtime Context. If you do Save As and create a new application version MyCo:01.01.02, System Runtime Context will automatically detect it and update it right away if you refresh the gadget.

  • For question #2:

Say, your current application structure and System Runtime Context are configured as below.

In this case, the rule resolution precedence is in the order of MyApp2:01-01-01, MyApp2Int:01-01-01, MyApp1:01-01-01, MyAppInt:01-01-01, MyCo:01-01-01, MyCoInt:01-01-01, Pega-ProcessCommander:08-08.

Next, you do Save As and create a new application version MyCo:01.01.02 that includes MyCo:01-01-02 and MyCoInt:01-01-02. At this point, as I said in question 1, System Runtime Context automatically detects this new version as below.

In this case, the rule resolution precedence is in the order of MyApp2:01-01-01, MyApp2Int:01-01-01, MyApp1:01-01-01, MyAppInt:01-01-01, MyCo:01-01-02, MyCoInt:01-01-02, Pega-ProcessCommander:08-08. Be noted, this change is made before you update MyApp2 to point to MyCo:01.01.02. As soon as you create new version of application in the platform, System Runtime Context detects the highest version regardless of individual application’s association. Hope this clarifies your question.

Thanks,

@pavankumarp6690

As I explained in the prior reply, whether you update MyApp1 or MyApp2 association does not matter. As soon as you save a new application rule version “MyCo:01.01.02” in the platform, system will immediately detect it and update MyCo from 01.01.01 to 01.01.02 in the System Runtime Context regardless of individual application’s association. System Runtime Context is shared across applications in a signle platform.

Thanks,

@KenshoTsuchihashi Thanks for providing the details around SRC. As was mentioned, due to limitation, PegaRULE:AsyncProcessor was removed and replaced by SRC.

Q1) what is the requestor type of Queue Processor(QP) and Job Schedular(JS)? if not ASYNProcessor requestor type, then how it is associated to QP, JS to provide?

Q2) Is SRC only applicable to JS and that also when Access Group is not defined in JS rule form? (because in QP, either the user’s AG (or alternate AG) provides the context).

Q3) As there is a dedicated table for SRC, means there can be multiple instances of SRC records; then is there way to associate the custom SRC to JS?