Map in Receive Port calling Instance Methods in C# DLL concurrency issues RRS feed

  • Question

  • We have a map that maps an Oracle PO to a Canonical.  The ship to and bill to address aren't in the Ooracle PO, so we call a C# to look them up and add to the Canonical (that's the way it was when I arrived on the scene). 

    Now that our volume is going up, we found that when 4 or 5 POs arrive into the BizTalk receive port at the same time, the addresses can get mixed up.  I even have a custom trace, and a GUID assigned is the same. 

    So does the map automatically create a new instance object from the class.  If same map is invoked at same time, would it share the same object?  

    I've have usually used static methods in the past, but in this case, was keeping some of the trace state variables so that all the methods wouldn't have to be changed to have those trace parms.  

    It seems like maybe the constructor is just called once time the BizTalk Instance is started, could that be right?  Thus it becomes a singleton? 


               BizTalk maps that call external assemblies call the default constructor 
            public OracleID()
                trcProgramName = "Map";
                trcCorrGuid = Guid.NewGuid().ToString();
                trcProgGuid = trcCorrGuid;
                trcKey = null; 



    Wednesday, December 4, 2019 11:33 PM


  • I was able to reproduce in our test environment when I dropped about 6 to 8 POs at the same time. (Prior in testing, I usually had same address on the POs, so would have never noticed this).   Seems like definitely a concurrency problem, race or memory being overwritten because multiple calling maps sharing the same C# object instance.  Definitely emphasizes the importance of stress testing.  (No QA team where I'm currently working.) 

    I created new C# static methods in a new class called "Static". In them, I then instantiate a new object and call the existing routines.  Changed map to call the Static version of same methods.  (Side note: I also changed the maps to pass the PO number and map name to all these static routines so they could be used in the trace). 


    • Marked as answer by Neal Walters Friday, December 6, 2019 9:31 PM
    • Edited by Neal Walters Friday, December 6, 2019 9:32 PM
    Friday, December 6, 2019 9:30 PM