How does Mendix session context work?

2
Hey all, I was wondering if someone could give me some insight into how Mendix uses context in user sessions (the only detailed post on the subject was for Mendix 2.4..). The questions stems from the following; with one of our applications, we were getting a warning 'object with [...] could not be retrieved'. The object that the message referred to had indeed been deleted previously, but none of the subsequent microflows made use of it. We tried to debug our application to find the cause, but the warning already showed before any of the microflows. So, we traced the HTTP traffic: This is the HTTP request for the microflow action in which the object is deleted (the culprit is 68398419340706410, let's call it object X): {"action":"executeaction","params":{"actionname":"ModuleName.MicroflowName"},"context":["63050394783209550","133982088914275963","23925373020426165","48413695994252935","68398419340706410"],"profiledata":{"1fef0e384396aa0":85,"1fef0e384515270":1178,"1fef0e384505980":1194,"1fef0e38439c430":1277}} Seems correct. Now the action that is called with the above request also opens a new page. On that page we then run an on-change microflow. Before this new microflow starts we already see the 'object X could not be retrieved' warning. The below HTTP request was fired when the on-change was triggered: {"action":"executeaction","params":{"actionname":"ModuleName.MicroflowName_2","applyto":"none"},"context":["115967690404809188","63050394783209550","133982088914275963","23925373020426165","48413695994252936","68398419340706410","63613344736713796","58546795155845967","55169095435318095","57702370225757403"],"profiledata":{"1fef0e609cc7860":70}} As you can see, 68398419340706410 is still in there. Now my guess is this: Object X was used in screen 1 and thus added to session context Object X was deleted in Microflow 1 when opening screen 2 and was also removed from memory Microflow 2 is triggered. The HTTP session context still contains reference to Object X. Mendix tries to retrieve this object before running the microflow, but can't find it But this is all guesswork, and the issue showed me that I don't exactly know Mx context works. So, can anyone out there enlighten me? In specific; how/when are objects added to session context, and how/when are they removed? Kind regards, Christiaan
asked
2 answers
4

The documentation page I linked to at the bottom of this post explains about the life-cycle of an object. I think it makes sense to start by reading through that to understand the basic behavior of an object. If you have additional questions based on this please add it to this thread or to the comments section in the documentation.

The problem is that it's not an easy answer, but I'm more than happy to start explaining this. The context is only a small piece that influences how an object passes through the platform. The mentioned documentation page doesn't explicitly mention context because for the high level explanation this isn't relevant.
One of the main functions of the context is to serve as a collection of information that can be passed through the different actions in the platform. The context itself doesn't do anything, but it is leveraged by every object related action. For example in Java you'll always need the 'context', because the platform uses this to get to the correct session and session cache.
The context parameter that you are referring to in your post is part of most messages that browser sends to the server. This context parameter is the method the platform uses to determine to see which objects are still used or accessible in the browser.


https://world.mendix.com/pages/viewpage.action?pageId=13566032

answered
1

I have some additional questions:

The documentation states that

Objects in content could remain available in the Client. When you open forms sequentially the user will always be able to use the back/forward buttons in the browser unless you close any previous forms.

When closing an in content page and opening a new in content page in the same transaction, I discover that objects on the closed page remain in context, while they are no longer needed on the newly opened page. Do you know why this happens?

Also the documentation says that objects linked to a user are always kept until the session ends.

  1. Is this also the case if you delete the object in a microflow?
  2. If an object always stores the 'owner', does this also count as being linked to the current user, or is this only true for associations?
  3. Are these objects also always present in the client, or will these be correctly updated when the object type is refreshed in the client?
answered