Forum Discussion

FabioG's avatar
FabioG
Contributor II
29 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

4 Replies

  • db_pdx's avatar
    db_pdx
    Valued Contributor

    I'll suggest: 

    BRApi.Utilities.StartDataMgmtSequence(...)

    We use this inside a 'for each' for executing multiple workflows in parallel by looping over a list profiles/parameters.  This calls each item of the list as an independent Data Management job which should eliminate any of your issues with POV sharing.

    • FabioG's avatar
      FabioG
      Contributor II

      Hi db_pdx​ ,

      thanks for your answer.

      Your suggestion is good (actually I don't see other ways, at the moment), but I was looking for something less "tricky". I mean, I am looking for a way to run them directly from code, without having to implement Data Managements or other "external" (from a code perspective) stuff.

      Anyway, thanks a lot for Your suggestion, I'll definitely try it !

      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

  • 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