Refresh in Client and Show Message activity does not work in a microflow executed from Java callback
I am using MQTT Connector to subscribe a topic and need to show topic messages to the user when they arrive. Below is a brief detail on how subscribe action works in MQTT MQTT Subscribe: This activity sets up the Subscription to an MQTT topic. When you execute this activity the module will setup a connection to the topic and wait for any message that comes in on the topic. On message Microflow (required): The Microflow that will be executed for each message on the Topic. This microflow must have 2 parameters of type String: Topic & Payload. The onMessageMicroflow is executed from a callback function in Java (MQTT connector source) So, in above scenario how to: Trigger “Refresh in Client” on an entity which stores the topic messages so that user can see latest messages when they arrive Use “Show Message” activity to directly show topic message in a dialog box to the user Both of above option do not work because user context in not available from where the onMessageMicroflow is executed. Is there any other solution to this problem? Any workarounds? I have tried passing user context (getContext()) parameter from the subscribe function all the way till callback used for executing onMessageMicroflow, and then execute the microflow with that context parameter. Still client activities like refresh or show message did not work Tried using refreshClass and refreshClassByObject functions from Community Commons module inside the onMessageMicroflow. It did not work I understand that we can execute microflow with user context from a java action and then client actions would also work. I was also able to implement it in a simple java action called from a microflow on button click inside Mendix. **This only works when microflow is executed directly from the user called Java function via microflow and not from any other registered callback function which itself is called from another location (like here in MQTT) One workaround/solution: Till now, I could only find one solution that is using Microflow Timer on the page and keep calling refresh in client on the entity or use some flag variable stored in database to check if refresh is required. Something similar could also be done for “show message” activity. Anyone having a better solution or any suggestions?
No experience with it, but I think the Pusher module does what you want
I’ve not tried this, but in your On Message Microflow, could you use Community Commons executeMicroflowAsUser (or one of the variations depending on exact needs) to execute a microflow in the correct user context that can then refresh the entity?