Forum Discussion

FabioG's avatar
FabioG
Contributor II
10 days ago

ExecuteCustomCalculateBusinessRule in parallel

Hi all,

so I'm running a Finance Business Rule through BRApi's ExecuteCustomCalculateBusinessRule method, passing a POV through its nameValuePairs parameter.

Since I need to run it from a WorkSpace for a bunch of different DataUnitPK, I'd like to run them in parallel. 

Unfortunately it doesn't work. It seems to me that:

  1. The first launch runs with a POV passed in parameters (let's call it POV-A)
  2. The second launch sets its own POV (let's call it POV-B)
    1. if the first launch is still running - and that's natural for parallel execution - every reference to api object seems broken, since it refers now to POV-B

Does someone was able to parallelize the above mentioned method ?

Thanks in advance for Your help

 

Regards

FabioG

2 Replies

  • FabioG's avatar
    FabioG
    Contributor II

    Hi sameburn​ 

    I'm doing exactly what You describe, but my problem is that I'm hitting different data units, and looks like resulting POVs are overlapping between parallel calls.

    Maybe, since You are not hitting the same Data Unit, you are not facing this issue.

    I'll build a test to better understand this issue.

    Thanks a lot for Your answer

    Regards

    FabioG

  • sameburn's avatar
    sameburn
    Icon for OneStream Employee rankOneStream Employee

    Hi FabioG​ 

    I have achieved something similar before.  In my use case I setup my Parallel.ForEach in an extensibility rule (where i was looping through datatable rows e.g. my source) and used the BRApi below to call my Finance Rule from the Extensibility rule (I passed in my variables using nameValuePairs dictionary)

    BRApi.Finance.Calculate.ExecuteCustomCalculateBusinessRule(si, brName, functionName, nameValuePairs, timeType);

    In my case it got more complicated as I was hitting the same data unit > once (so i needed some kind of balancing buffer)

    But maybe this helps :)

    Sam