0

At the moment i am using prime push to send a refresh command to the client's jsf page and the jsf page will then reload itself and render the changes. It looks something like that:

Server:

EventBus eventBus = EventBusFactory.getDefault().eventBus();
eventBus.publish("/event/" + eventId, "updateEntries");

Client:

<p:socket channel="/event/#{detailController.id}" onMessage="handlePush"/> 
<script type="text/javascript">
    function handlePush(msg) {
        switch (msg) {
            case "updateEntries":
                updateEntries();
                break;
        }
    }
</script>

<h:form>
    <p:remoteCommand name="updateEntries" actionListener="#{detailController.reloadEntries()}" update="entries" />
</h:form>

However this works pretty well but i think if i have more clients this will become a performance issue because every client requests the hole data at the same time.

My idea was to encode the entity which changed/added and transfer the json via the push to the client and decode the json and add it to the datatable.

Is there any other way how to deal with a large number of clients which need instant updates?

perotom
  • 851
  • 13
  • 33
  • This is a generic 'push related issue. It is not PF, not JSF (not at all), and not atmosphere related. You can/should optimize things by using caching of the data, maybe even use caching of parts of the facelets. Or by not updating directly, but just showing the user that new data is available and a click by the user is required. This latter option will distribute the requests a little – Kukeltje Feb 10 '16 at 10:09
  • So you mean it is more of a general problem. I am not quite sure how to handle this problem. From a general view i would say it is most efficient to push the changed/added data to the client´s browser and there handle the update of the view. Maybe jsf is the wrong technology for this kind of purpose? Maybe i should use angular? – perotom Feb 10 '16 at 10:16
  • Depends on what data... If you actively push all the data when using angular, you have the same problem, maybe a little (unless it is 'plain' json data. You can still make sure the `remoteCommand` does not submit anything by e.g. using `process='@none'` and `partial-submit="true"`. You can also use a small random time-out on the client (between 0-10 second) to distribute the load. And how many clients are you thinking of? Maybe the problem is not as big as you think (if at all) – Kukeltje Feb 10 '16 at 10:51
  • The data is very small (just approx. 30 chars). I am talking about 1000 clients who all get the changes instantly – perotom Feb 10 '16 at 18:20

0 Answers0