ajaxjmspushlisteneropenxava

Updating certain view programmatically from a JMS listener class


I was able to integrate ActiveMQ and create a JMS consumer into my OpenXava application. Now, I need to update certain transient view with the data received in the message, which it have several issues to consider, by example... how to go from a JMS listener java class and push the changes to the current view? ... and supposing the specific view is the current!!!, but the current view could be any one of the several possibles views in the whole application!!! ... so? so?... then I did think, I will persist the JMS messages into some entity (as a temporal storage in DB) even that will incur in a low performance, but then after that... how I will push the recent changes if some user is looking the transient view.

I was used to build my webapps using some JSF implementation with ajax enabled, and then I could receive the message in the JMS listener and then get a jsf managed bean reference and use Ajax push to refresh all the sessions that could be opened by one or several users looking into the app, so this always produced a kind of real time application, which update the any opened view (if the view is the one that the user is watching).

So, is there a way to accomplish that with a JMS listener class into my OX app??

Thanks in advance,


Solution

  • An option can be using JavaScript to calling regularly to know if a new record is added in the table or whatever, and if it is case refreshing.

    If you're liferay you can create a portlet in that page with the JavaScript code. This code can do the call using DWR, and if there is new data it can call to the "CRUD.refresh" action directly.

    Something like this:

    refreshData = function() {
       openxava.executeAction('YourApplication', 'YourModule', '', false, 'CRUD.refresh')
       setTimeout('refreshData()', 5000);
    }
    setTimeout('refreshData()', 5000);
    

    I didn't test this code, so surely it does not work as is. Take it as an idea.

    Really, this is a dirty trick. The ideal would be that OpenXava would have direct support for comet, you could accomplish this just calling to an method in the server. Do you think that adding comet support to OX worth?