So we are using a common state context singleton with a correlation ID for centralized Logging. The purpose is to track the id throughout our entire process and correlate the different tiers.
The state context is accessed by multiple dlls and multiple users.
The difficulty comes when multi threading comes into play:
- Process 1 has fired by user 1
- Correlation ID gets set to {1}
- DLL A accesses state context and gets correlation ID {1}
- Before process 1 is completed, Process 2 has fired by user 2
- Correlation ID gets set to {2}
- DLL B from 1st process access state context with correlation id {2} when it should be {1}
How do we solve this issue?
We do not perceive locking to be our solution? Any other ideas?
Here is a diagram
(S)->[ CorrelationID {get;set} ]
^ ^ ^
U1 <--> | | | O
U2 <--> [DLLA] <--> [DLLB] <--> [DLLC] <--> | |
U3 <-->
{Web} <--> {Domain} <-> {Data Access} <--> {DB}
(<-- Process / Thread --> )
{} = Examples of possible DLLs
Each User's process should have 1 correlation ID