Symptoms
According to the K2 documentation at https://help.k2.com/onlinehelp/k2blackpearl/userguide/4.6.6/webframe.html_endpoint_service_brokers.html, all method calls should be considered as stateless.
However, state is contained in the class called by the endpoint service broker. Is it by design? How this actually works?
Use case/background for the question: “Some of the code running in our context requires cleaning up resources manually and we want to avoid any potential memory leaks.”
Diagnoses
N/A
Resolution
Any static values are stored on the AppDomain (an isolated region in which code runs inside of a process), this behavior is by design for .NET and not defined by K2. I.e., it can store static state objects in memory, but this is not recommended.
There state will be kept until the server restarts or if the code sets it to null. Furthermore there are many issues where static data is breaks when the user load increases. For example Multi-Threading and NLB can store the one call on Server1 object store, but the next call ends on Server2 where the static values are set to null.
Some customers do the same in their process’s code behind. The data is then saved on a static instance, so that the value can be shared between process instances, because all process instances of the same process definition run on one app domain."
For details about AppDomain please refer to:
https://msdn.microsoft.com/en-us/library/system.appdomain.aspx
Method calls are stateless because the “content of interest” is not affected or dependent on data persisted first by an earlier method call on the target endpoints service of interest. Configuration data is persisted on either endpoint, but that regulates the Service Instant and methods, and does not handle “content of interest.”
You might build a composite SMO which uses Service Object methods which first deserialize and such, and use their result set in the next service object method and that “flash” state is maintained by the SmartObject Framework within handling a composite SmartObject definition. The method calls hitting the target endpoint is still stateless.