Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    How to indicate another DataSource changed on server

    I have the following situation. I am using some DMI DataSources that on an update, may cause changes in another DataSource. For example, update of DS1 introduces a new record in DS2.

    Is there a nice and/or efficient way to send these changes back to the client?

    I can think of a few mechanisms:

    1) force DS2 to be refreshed (invalidCache) on any DS1 update from the client

    2) continually check the server for changes by polling using an RPC. If a DS has changed, send back the rows.

    3) indicate changes to the other DS in the DSResponse - perhaps by adding extra data to the response. The most efficient thing I can think of is to send back a (list of (map of DS -> changed records)). Is there something like this built in?

    Thanks in advance for any pointers.

    #2
    I'd be very interested in any insights regarding this, too. I've been thinking about a server-push to synchronize the datasources' states:

    http://code.google.com/p/gwt-comet/

    regards,
    Andrius J.

    Comment


      #3
      See this post.

      Note that we don't recommend Comet (inclusive of our Messaging solution) unless you're looking for <250ms latency delivering data. Comet is fairly resource intensive (one connection open at all times per client), so polling makes more sense until you have strictly latency requirements.

      Comment


        #4
        Andrius - did you ever do anything on this? I had a bash at keeping a grid datasource updated (an admin logging grid) yesterday, and it did strike me it might be easier to write a generic datasource sync tool.

        The ideal features would be:

        * Can use either polling or comet (or GAE channel API, or what ever other connection mechanism you like)

        * No client code changes - bar the creation of the datasource.

        It seems the mechanism should use DataSource.updateCaches() to push changes to the client datasource. I'm yet to see a complete clear example of how to do this.

        http://forums.smartclient.com/showthread.php?t=11798
        http://forums.smartclient.com/showthread.php?p=52563
        http://forums.smartclient.com/showthread.php?t=14370
        http://forums.smartclient.com/showthread.php?t=13028

        My understanding is that the following sort of code should work

        Code:
          ConnectionHandler
          onUpdate(DSResponse r){ 
              DataSource.get(r.getDataSource()).updateCaches(r)
          }
        On the server side, we need have to keep a register of each client that is connected and which datasources they are listening to. On an update/add the DSResponse is sent to all registered clients via whatever connection mechanism we're using.

        Does this sound like a sane and straightforward way of achieving client/server data syncing?

        Comment


          #5
          The code is actually this:

          Code:
          ConnectionHandler
             public void execute(DSResponse response,
                                       Object rawData, 
                                        DSRequest request) {
              request.setOperationType(DSOperationType.UPDATE);
              DataSource.get(request.getDataSource()).updateCaches(response, request);
            }
          Which 'fakes' a local update in the datasource.

          One thing that is strange, it complains that there is no "id" value set although there is (the first error message is a debug print of the record being updated). The grid updates successfully however, so I think I can ignore the warning.

          Code:
          [ERROR] [example] - 15:27:12.283:XRP5:WARN:Log:id=3450:businessAccount id message time userAccount 
          [ERROR] [example] - 15:27:12.286:XRP5:WARN:Log:findByKeys: passed record does not have a value for key field 'id'

          Comment


            #6
            The error message makes sense, since this is a new record (as pointed out by Isomorphic in the referenced thread above). I guess what I could do is check the local cache and split records into an add and an update? The add operation looking like:

            Code:
              request.setOperationType(DSOperationType.ADD);							
              DataSources.log.updateCaches(response,request);
            It makes me wonder though, since the code with UPDATE works, does it matter?

            Comment

            Working...
            X