The basic idea: I have a backend server that calculates data and sends it to the Mendix frontend. These calculations take a long time, so I want to start the calculation with a PUT request and then check later for the results with a GET request.
The problem: When I add a delay to a microflow in Mendix between the PUT and the GET request, the page does not load during this time, because obviously the microflow has not finished yet. So instead, I call a Java Action that creates a new thread and this thread then calls the microflow with a delay from this separate thread. This works fine, if I just log messages to the console with the delayed microflow. But if I want to change anything that is shown to the user on the webpage, the changes are not visible. I know that the delayed microflow is running, because of the log messages, but I can not call something like a Show Page Activity. I also tried just changing Entities in the Database, but even then the Dataviews on the user’s webpage would not update.
It seems like there is some problem with the context variables. When I call the microflow from a separate thread, it has a different context than the main thread, so the changes it makes to the Client will not be shown to the user. Is there a way to fix this? Is there any way to change something in a different thread and then make these changes visible to the original user?
I would use the microflow timer widget for this, save the hassle of setting up threads in java and allows for changing stuff on the page.
You’ll find the widget herehttps://appstore.home.mendix.com/link/app/27/Mendix/Microflow-Timer