Page 1 of 1

Handling UI relevant stuff from a RabbitMQ-Event

PostPosted: Fri Aug 23, 2019 10:52 am
by rph
Hi everybody

We have the following situation:

Our application (a Servoy-SmartClient-Application) communicates with another Web-Application (a special map-application). The communication between our two apps works over a Messaging-System (RabbitMQ). This works as expected as long as we don't need to make UI like opening a form to show some information to the client.

For example: in the web-app the user clicks on a house and selects "show detail information in servoy app". This fires an event to RabbitMQ. In our Servoy-App we have a listener that takes this Event and should now open the specific Form to show the content.

We receive the event, but if we try to open the form, it throws an exception that the form is not already opened. If I open the form manually within our application AND THEN go the web-app and select the event, then the form comes to front and shows the right record.

I guess the problem is, that the event-handler for RabbitMQ is in a worker thread. But, how can I handle UI relevant stuff from the worker thread?

Thanks for any suggestions.

Best regards
Roland

We use: Servoy 8.1.4 / Servoy Framework / Java 8 U211

Re: Handling UI relevant stuff from a RabbitMQ-Event

PostPosted: Fri Jan 08, 2021 2:37 pm
by rph
Just if somebody ever have a simular issue, here's my workaround: in the Event-Handler I start a new job with "plugins.scheduler.addJob". This brings me back to the Main-Thread and I can do do all the UI-stuff within this Job!

Re: Handling UI relevant stuff from a RabbitMQ-Event

PostPosted: Tue Jan 12, 2021 1:05 pm
by mboegem
rph wrote:Just if somebody ever have a simular issue, here's my workaround: in the Event-Handler I start a new job with "plugins.scheduler.addJob". This brings me back to the Main-Thread and I can do do all the UI-stuff within this Job!


Yes, this is a way to defer method execution, and will help to resolve some of the issues you mentioned.
plugins.scheduler.addJob (even with immediate execution time) will schedule a job, but as Servoy is single threaded, the execution won't start until the current method has been completed.