Multitenant scheduled event

3
In a multitenant environment a certain background job calls community commons executeAsUser because the microflows have 'Apply entity access' enabled and this must absolutely be executed as a user. The microflows runs for more than 15 minutes and the Log is flooded with messages that Mendix can not delete the session. If we change the executionType of the microflow to SCHEDULED_EVENT the messages disappear but the cache is corrupted with orphan objects with owner UNKNOWN. We have increased the sessionTimeout but that has unwanted side-effects Is a solution available for this? EDIT1: After building a test project that successfully shows this behavior we found that setting the context executionType to CUSTOM will solve this.
asked
1 answers
1

You could consider doing a keepalive during your long running microflow? The Java API from ISession contains a keepAlive() function, you can consider to do this at strategic places in your microflow?

You don't want to overdo this but if on specific places in your microflow you'd run the function: this.getContext().getSession().keepAlive(); it would keep the session active and preventing the platform from collecting the session.



Also please note this keepAlive only works if you don't persist the sessions (without clustering). The keepAlive() function isn't one of our platform supported APIs and doesn't capture all cases. If you use clustering or persistentSessions you'll have to update and commit the session LastActive attribute field to the current date. This will make the platform think that the session was active.


BTW if you set the sessionTimeOut I would also recommend setting the customSetting: ClusterManagerActionInterval to reduce the unwanted effects. (Without specifying it the cluster manager is running twice per sessionTimeOut increasing this can have unwanted results).
See here for reference

answered