How/When are CORs loaded & executed ?

Discussions concerning general integration topics.

Moderator: Phil Barton

Post Reply
toddsou
Posts: 75
Joined: Wed Jul 25, 2012 9:39 am

How/When are CORs loaded & executed ?

Post by toddsou »

Hi-

I'm looking for a memory leak, and I suspect one or more of our Custom Order Rules.

In order to understand how the hosting script engine and scope are created, used, and disposed within Select, can you elaborate on the timing of when things happen?

Is one engine created per Select Session ? Is one ScriptScope created per order ? Is it disposed when the open order is closed ? etc.

Thanks.

-Todd
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: How/When are CORs loaded & executed ?

Post by BobRichards »

I am not an authority on this subject but I can get you started.

Let's assume you've opened an existing order. During the process of opening, the order blog is deserialized by Select. The order's CORs are in the order blog along with everything else about the order. As the order is being deserialized (or immediately there after), all the CORs and built-in rules run. Sometimes rules may run multiple times as they settle down to the final state. Sometimes they run multiple times when (for example) a Contact is created but it has not been added to the Contacts collection. In this case, in all cases, test the Parent property (if present) and if it is "None", exit the rule immediately. When the Contact is added to it's collection, it will call the Value aspect rule again then when you test for the Parent property, it will be non-null and you should set properties. Sometimes rules test the value of other rules (creating "dependencies") and the rule will rerun each time a dependency changes.

Once all the rules have run and no more are queued, we set the order's dirty flag to false and the "Save" button will turn off.

The order is now open.

Be aware that this happens on the Server also when an Automation Snipper is run.
Bob Richards, Senior Software Developer, SoftPro
toddsou
Posts: 75
Joined: Wed Jul 25, 2012 9:39 am

Re: How/When are CORs loaded & executed ?

Post by toddsou »

Thanks for the info, Bob.

Can you elaborate on the lifetime of the CORs IronPython interpreter/engine during these events?

Is a new engine created with each order? Or is a single instance of it reused during a SPS session ?

Regards,
Todd
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: How/When are CORs loaded & executed ?

Post by BobRichards »

This aspect is not important - what is important is that orders will always run in logically separate scopes that cannot co-mingle with other orders. Remember that the underlying engine is an IronPython .NET component so the code is loaded then compiled using the DLR (Dynamic Language Runtime). Dynamic code is much faster than interpreted.
Bob Richards, Senior Software Developer, SoftPro
Post Reply