Handling UI relevant stuff from a RabbitMQ-Event

Questions and answers on designing your Servoy solutions, database modelling and other 'how do I do this' that don't fit in any of the other categories

Handling UI relevant stuff from a RabbitMQ-Event

Postby rph » Fri Aug 23, 2019 10:52 am

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
rph
 
Posts: 51
Joined: Wed Aug 10, 2011 11:44 am
Location: Cham, Switzerland

Re: Handling UI relevant stuff from a RabbitMQ-Event

Postby rph » Fri Jan 08, 2021 2:37 pm

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!
rph
 
Posts: 51
Joined: Wed Aug 10, 2011 11:44 am
Location: Cham, Switzerland

Re: Handling UI relevant stuff from a RabbitMQ-Event

Postby mboegem » Tue Jan 12, 2021 1:05 pm

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.
_____________________
Marc Boegem
Solutiative / JBS Group, Partner
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance SAN Developer

Image
User avatar
mboegem
 
Posts: 1573
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam


Return to Programming with Servoy

Who is online

Users browsing this forum: No registered users and 6 guests

cron